diff --git a/brotherax240_cntrl/src/main.cpp b/brotherax240_cntrl/src/main.cpp index e194956..dabfe16 100644 --- a/brotherax240_cntrl/src/main.cpp +++ b/brotherax240_cntrl/src/main.cpp @@ -9,7 +9,7 @@ bool use_rn=false; //if use_rn=true, CR and LF only do what they say. if use_rn= //To upload set Boot0 jumper to 1 (the one further away from reset btn) and press reset (stm will boot from flash wich contains uart to flash uploader) //To boot program after restart set Boot0 jumper to 0 -//#define DEBUG +#define DEBUG #define CHECK_BIT(var,pos) ((var) & (1<<(pos))) @@ -19,7 +19,7 @@ bool checkTextbuffer(); void sendChar(char c,char c2); void coilInterrupt(); -//pins die nicht gehn als output: +//The following gpio pins do not work as output: /* PA15 * PB3 * PB4 @@ -314,6 +314,7 @@ bool checkTextbuffer(){ } void sendChar(char c,char c2) { //c2 =0 for 1 byte characters + static bool waitFormatChar=false; //when format start character received, set this true. Next char will be format command uint8_t keypress[NUM_SCANPINS]={0}; //keypress contains id of input pin. 0=not pressed, A=2^0, B=2^1, C=2^3 ... //check if key is implemented (not all 255,255,255,..) @@ -324,28 +325,72 @@ void sendChar(char c,char c2) { //c2 =0 for 1 byte characters } } - if (keyimplemented && ( (c>=32 && c<127) || c==10 || c==13 ) ) { //1 byte char - #ifdef DEBUG - Serial1.println("1 byte char"); - #endif - for (uint8_t i=0;i=32 && c<127) || c==10 || c==13 ) ) { //1 byte char + #ifdef DEBUG + Serial1.println("1 byte char"); + #endif + for (uint8_t i=0;i=32){ //not recognized character (everything else) and not a control command + if (!waitFormatChar) { + if (c==92) { + waitFormatChar=true; + #ifdef DEBUG + Serial1.println("Waiting for Format Char"); //echo + #endif + return; //stop function, do not print anything + }else{ + keypress[1]=128; // [SPACE] //print space to keep text aligned + } + } } - }else if(c==194){ //others - if (c2==167){ // § - keypress[0]=128; keypress[7]=16; //shift + 3 - }else if (c2==176){ // ° - keypress[1]=32; keypress[3]=8; //CODE + W - } - }else if(c>=32){ //not recognized character (everything else) and not a control command - keypress[1]=128; // [SPACE] //print space to keep text aligned }