Understanding the language, error messages, etc.
by Awot » Wed Feb 15, 2017 2:50 pm
Hello,
I would like to print each alphabet letters with a Serial.print(..
in the wiki, the gb.display.print page it is said : Serial.print("\7") gives an empty battery symbol
and the ASCII table :
- ascii table.png (4.32 KiB) Viewed 10986 times
So i suppose we could read the alphabet by incrementing a "Letter" variable like this :
Serial.print("\" & Letter)
<= Something like these but i don't know how to do here ? (And "Letter" would be from 101 to 132, and avoiding all number after 7 => 101, 102, 103, 104, 105, 106, 107, 110, 111... )
So my question : how to use a variable "Letter" in a : Serial.print("\...") to print ASCII table ??
thanks
-
Awot
-
- Posts: 39
- Joined: Wed Jan 18, 2017 4:32 pm
-
by Awot » Thu Feb 16, 2017 11:13 am
Hello,
i will answer my question, here is what i found :
Using : gb.display.drawChar(x, y, char, size);
the "char" is the number of the
Decimal character in the ASCII printable characters table
so 65=A ... -> 90=Z
and not the
HEX char in the tables below :
- char_map.png (4.01 KiB) Viewed 10972 times
and not the
OCT char int the table in my fist post
so HEX 41 = DEC 65 = OCT 101 = "A" ect..
all this can be found here :
http://www.ascii-code.com/also in order to have real uppercase character we need to use
- Code: Select all
extern const byte font5x7[]; //a large, comfy font
and
- Code: Select all
gb.display.setFont(font5x7);
e.g. this program print a big uppercase Z character :
- Code: Select all
#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;
extern const byte font5x7[]; //a large, comfy font
void setup(){
gb.begin();
gb.display.setFont(font5x7);
}
void loop(){
if(gb.update()){
gb.display.drawChar(10, 10, 90, 3); // here 90 =Z , 65 = A .. 66=B ...
}
}
-
Awot
-
- Posts: 39
- Joined: Wed Jan 18, 2017 4:32 pm
-
by Sorunome » Thu Feb 16, 2017 2:41 pm
Awot wrote:Hello,
i will answer my question, here is what i found :
Using : gb.display.drawChar(x, y, char, size);
the "char" is the number of the Decimal character in the ASCII printable characters table
so 65=A ... -> 90=Z
and not the HEX char in the tables below :
[...]
This is a thing of C++, by default putting numbers is just decimal.
Let's say you put 16, if you want to do that in hex you can just do 0x10 or in octal that is 0o20 or in binary that is 0b10000.
Notice the different prefixes, no prefix means decimal, 0x means hex, 0o means octal, 0b means binary
-
Sorunome
-
- Posts: 629
- Joined: Sun Mar 01, 2015 1:58 pm
-
Return to Programming Questions
Who is online
Users browsing this forum: No registered users and 3 guests