Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * This function handles the message, and set it up on the screen. This function also handles swedish characters such as
- * å, ä, ö, Å, Ä, Ö which need some extra consideration.
- */
- void message_handler() {
- String message_string; // A string to hold the message
- boolean special=false; // If special true a special chracter is present
- char c; // Chars to hold temporary characters from the message
- int c_temp;
- char s[2] = " "; // A char array to deal with special characters
- unsigned char xpos=0; // x and y position to handle the position of the text.
- unsigned char ypos=19;
- message_string=current_notif->message;
- Serial.begin(9600);
- Serial.println( current_notif->title); // Draws the title and a line
- u8g.drawLine(0,9,127,9);
- // Iterate through the whole message, chech if special character, and put character on screen.
- for(int i=0; i<message_string.length();i++){
- c=message_string[i];
- c_temp=c;
- if(c_temp==-61){
- i++;
- special=true;
- c_temp=message_string[i];
- switch(c_temp){
- case -123: //Å
- s[0] =197;
- break;
- case -124: //Ä
- s[0] =196;
- break;
- case -106: //Ö
- s[0] =214;
- break;
- case -91: //å
- s[0] =229;
- break;
- case -92: //ä
- s[0] =228;
- break;
- case -74: //ö
- s[0] =246;
- break;
- }
- }
- if(xpos<=121 && ypos==19 && i<37){
- if(special){
- u8g.drawStr(xpos,ypos,s);
- }
- else{
- u8g.setPrintPos(xpos,ypos);
- u8g.print(c);
- }
- }
- else if(i<37){
- if(xpos>121){
- xpos=0;
- }
- ypos=30;
- if(special){
- u8g.drawStr(xpos,ypos,s);
- }
- else{
- u8g.setPrintPos(xpos,ypos);
- u8g.print(c);
- }
- }
- else{
- u8g.drawStr(xpos,ypos,".");
- }
- special=false;
- xpos=xpos+6;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement