I need help creating a simple input routine that allows users to letters for a warmup.
so I decided to create a function.


Code:
char get_input(const char text, const int x, const y);
// example: get_input("Day: ", 0, 0);
// returns: monday


I have the basic display worked out. but I need a way to detect the key number. I know I can map out each key to its ASCII Char but ... I wanted it optimized.

how do I create optimized code in C. so I don't have to map out each and every key to its char?
There’s an example for this in the documentation, which uses the values returned by os_GetCSC to access a char stored in a string, and append it to a temporary string used for the input. Here is the link to the description for the os_GetCSC function in the documentation, and the example of how to use this to make an input routine.
epsilon5 wrote:
There’s an example for this in the documentation, which uses the values returned by os_GetCSC to access a char stored in a string, and append it to a temporary string used for the input. Here is the link to the description for the os_GetCSC function in the documentation, and the example of how to use this to make an input routine.


Thank you this was very useful.

Question:
I have been trying to replicate the sine wave on CE.
turn out the CE screen can not display float points. and if it does it turns into int the display then point

Example: 4.89 will turn to 489 or even 4.

some may say turn the float to int. ex 0.1 will turn to 0

so how do I make sine wave?
At the risk of sounding like Mateo:
I have zero idea what you're asking.
Could you please repeat your question, preferably with proper grammar?
commandblockguy wrote:
At the risk of sounding like Mateo:
I have zero idea what you're asking.
Could you please repeat your question, preferably with proper grammar?


sure.

"How do I replicate a sine wave ( on the gfx screen ) ?"
I mean, if you just want a sine wave, you could just do

Code:
for(x = 0; x < LCD_WIDTH; x++) {
    gfx_SetPixel(x, vert_scale * sine(horiz_scale * x) + LCD_HEIGHT / 2);
}

Where vert_scale and horiz_scale are floats representing vertical and horizontal scaling, respectively.
That's going to be super slow, though, so if the actual sine wave isn't changing and you want to redraw it every frame, it would be better to make a repeating sprite and draw that.

I'm not sure what any of that has to do with float-to-integer conversion or the screen displaying floats, though.
commandblockguy wrote:
I mean, if you just want a sine wave, you could just do

Code:
for(x = 0; x < LCD_WIDTH; x++) {
    gfx_SetPixel(x, vert_scale * sine(horiz_scale * x) + LCD_HEIGHT / 2);
}

Where vert_scale and horiz_scale are floats representing vertical and horizontal scaling, respectively.
That's going to be super slow, though, so if the actual sine wave isn't changing and you want to redraw it every frame, it would be better to make a repeating sprite and draw that.

I'm not sure what any of that has to do with float-to-integer conversion or the screen displaying floats, though.


Thank you for that Good Idea .
Also, I thought if I try to display a decimal on the LCD screen C converts the decimal into an int by removing the decimal point.

Question:

How do I set an RGB transparent color in Convpng?

Do I do something like this?

Code:
#GroupC        : sprites
#TransparentColor : rgb(233, 22,122)?
#Palette         : xlibc
# PNGImages :
        example
        example
        ...
The tranparent color values should just be the RGB values:

Code:
#GroupC           : sprites
#TransparentColor : 233, 22, 122
#Palette          : xlibc
Captain Calc wrote:
The tranparent color values should just be the RGB values:

Code:
#GroupC           : sprites
#TransparentColor : 233, 22, 122
#Palette          : xlibc



I thought so. it's still not working ... I made sure the RGB colors matching the ones in the image then I recompiled the image I removed the compiled C files and recompiled. it still is not displaying a transparent sprite but it's displaying a normal sprite.
Just to be sure, which sprite function are you using? If you want a sprite to be transparent, you have to use gfx_TransparentSprite() or similar, you can't just use gfx_Sprite().
Jeffitus wrote:
Just to be sure, which sprite function are you using? If you want a sprite to be transparent, you have to use gfx_TransparentSprite() or similar, you can't just use gfx_Sprite().


Quote:
8:32:47 PM [Captain Calc] You should also call gfx_SetTransparentColor() before drawing the sprite as well


Thank you Very Happy . I thought C some automatically sets the transparent color. So what is the point of defining the transparent color in the Convpng file? Confused
I am definitely not an expert on ConvPNG, but I believe the reason for defining the transparent color in the .ini file is that, if permitted, ConvPNG will convert the sprites using as few palette indices as possible. This makes the custom palette included in your program much smaller than the standard palette of 256 colors.

However, if you let ConvPNG build a syncopated palette, the palette indices that apply to the standard palette (e.g. 0 = BLACK, 255 = WHITE, etc.) will not work on the custom palette which will have its own indices for each color. To help you remember which index corresponds with which color, ConvPNG allows you to specify fixed color indices as well as labeling them in the .ini file. Here is part of the convpng file for Mental Math CE:

Code:
#GroupC              : sprites
#TransparentColor    : 255, 0, 255
#FixedIndexColor     : 1, 104, 159, 56, BG_COLOR
#FixedIndexColor     : 2, 85, 139, 47, BG_SHADOW_COLOR
#FixedIndexColor     : 3, 0, 0, 0, BLACK
#FixedIndexColor     : 4, 199, 107, 26, BROWN
#FixedIndexColor     : 5, 255, 170, 0, HIGHLIGHT_YELLOW
#FixedIndexColor     : 6, 255, 255, 255, WHITE
#FixedIndexColor     : 7, 116, 255, 3, GREEN
#FixedIndexColor     : 8, 220, 237, 200, LT_GRAY


The first number in the list of arguments for #FixedIndexColor is the palette index. The label at the end is the name for the color which you can use in GraphX functions (e.g. gfx_SetColor(BG_COLOR) ).
Captain Calc wrote:
I am definitely not an expert on ConvPNG, but I believe the reason for defining the transparent color in the .ini file is that, if permitted, ConvPNG will convert the sprites using as few palette indices as possible. This makes the custom palette included in your program much smaller than the standard palette of 256 colors.

However, if you let ConvPNG build a syncopated palette, the palette indices that apply to the standard palette (e.g. 0 = BLACK, 255 = WHITE, etc.) will not work on the custom palette which will have its own indices for each color. To help you remember which index corresponds with which color, ConvPNG allows you to specify fixed color indices as well as labeling them in the .ini file. Here is part of the convpng file for Mental Math CE:

Code:
#GroupC              : sprites
#TransparentColor    : 255, 0, 255
#FixedIndexColor     : 1, 104, 159, 56, BG_COLOR
#FixedIndexColor     : 2, 85, 139, 47, BG_SHADOW_COLOR
#FixedIndexColor     : 3, 0, 0, 0, BLACK
#FixedIndexColor     : 4, 199, 107, 26, BROWN
#FixedIndexColor     : 5, 255, 170, 0, HIGHLIGHT_YELLOW
#FixedIndexColor     : 6, 255, 255, 255, WHITE
#FixedIndexColor     : 7, 116, 255, 3, GREEN
#FixedIndexColor     : 8, 220, 237, 200, LT_GRAY


The first number in the list of arguments for #FixedIndexColor is the palette index. The label at the end is the name for the color which you can use in GraphX functions (e.g. gfx_SetColor(BG_COLOR) ).


Thank you Very Happy . That explains a lot, this means I did not have to define transparent color in the .ini file unless I have a fixed index color.

Question

I have been getting into cursors sprites with buffering. but the main issue is that I have to always reprint the GUI every time I move the cursor.

"How do I display the cursor sprite without redisplaying the GUI to allow the buffering to display faster?"

Quote:
6:08:46 PM [Captain Calc] @Alvajoy: You should take a look at the sprite examples in the C SDK. It sounds like you need gfx_BlitRectangle() and/or gfx_GetSprite()


I will still have to redraw GUI over again. when I grab a buffer where the cursor has been twice the buffered sprite will come out wacky. I also thought about making a list full of the cursor last position to check if the new draw cursors what hit that point it would redraw the UI turns out that did not work either.
Alvajoy123 wrote:
"How do I display the cursor sprite without redisplaying the GUI to allow the buffering to display faster?"

https://github.com/CE-Programming/toolchain/wiki/GraphX-Library:-Partial-Redraw
MateoConLechuga wrote:
Alvajoy123 wrote:
"How do I display the cursor sprite without redisplaying the GUI to allow the buffering to display faster?"

https://github.com/CE-Programming/toolchain/wiki/GraphX-Library:-Partial-Redraw


This worked just fine. Thanks, Mateo!!
Question:

Is it possible to scale down a sprite smaller than it's already is? Wink


Code:
for example:
gfx_ScaledSprite(data, -1, -1);
gfx_ScaleSprite.
MateoConLechuga wrote:
gfx_ScaleSprite.

MateoConLechuga++ Thank you Smile

Question
Does the font library only use .fnt files or it uses other types of font files such as .ttf?

why does the font library only use .fnt files?
Alvajoy123 wrote:
Question
Does the font library only use .fnt files or it uses other types of font files such as .ttf?
why does the font library only use .fnt files?

It supports only .fnt files and .fon files.
A .fnt file is a single bitmap font, meaning that it contains the exact pixel data required to display the font.
A .fon is a collection of multiple .fnt files that can contain multiple font styles/sizes similar to .ttf, but still contains bitmap data.
A .ttf file contains vector data, meaning that instead of exact bitmap data, it contains the shape of each letter in a way that can be scaled (like a collection of .svg files), as well as anti-aliasing metadata. This would be very big on-calc, and rendering .ttf fonts at a decent speed would also be very hard.
calclover2514 wrote:
Alvajoy123 wrote:
Question
Does the font library only use .fnt files or it uses other types of font files such as .ttf?
why does the font library only use .fnt files?

It supports only .fnt files and .fon files.
A .fnt file is a single bitmap font, meaning that it contains the exact pixel data required to display the font.
A .fon is a collection of multiple .fnt files that can contain multiple font styles/sizes similar to .ttf, but still contains bitmap data.
A .ttf file contains vector data, meaning that instead of exact bitmap data, it contains the shape of each letter in a way that can be scaled (like a collection of .svg files), as well as anti-aliasing metadata. This would be very big on-calc, and rendering .ttf fonts at a decent speed would also be very hard.


That explains a lot. I still need to know how to convert .fon to appvars as for .fnt it works fines.

Question
I need help with os_GetAnsData(); also known as os_RclAns();. This function returns a pointer (PTR) to where Ans data. *correct me if am wrong*. The ptr is a uint8_t. I want to get the chars from it the pointer.

How do I get the data (char) from the given pointer?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement