add format commands: underline, bold, move up, move down
This commit is contained in:
parent
98d41e090a
commit
77b6947eda
|
@ -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<NUM_SCANPINS;i++){
|
||||
keypress[i]=keymatrix[c][i]; //copy keypress connections for current char
|
||||
if (waitFormatChar) { //is waiting for formatting command
|
||||
if (c==98) { //b
|
||||
#ifdef DEBUG
|
||||
Serial1.println("Format: Bold"); //echo
|
||||
#endif
|
||||
keypress[0]=64; keypress[2]=16; //ALT + ArrowDown(Top Right Key)
|
||||
}else if (c==117) { //u.
|
||||
#ifdef DEBUG
|
||||
Serial1.println("Format: Underline"); //echo
|
||||
#endif
|
||||
keypress[0]=64; keypress[2]=128; //ALT + ArrowRight(one left to Top Right Key)
|
||||
//Changing Underline Mode cycles through: OFF, KON (unlineline spaces), WRT (underline only letters)
|
||||
}else if (c==106) { //j
|
||||
#ifdef DEBUG
|
||||
Serial1.println("Format: Move Down"); //echo
|
||||
#endif
|
||||
keypress[2]=16; //ArrowDown(Top Right Key)
|
||||
}else if (c==107) { //k
|
||||
#ifdef DEBUG
|
||||
Serial1.println("Format: Move Up"); //echo
|
||||
#endif
|
||||
keypress[1]=32; keypress[2]=16; //CODE + ArrowDown(Top Right Key)
|
||||
}
|
||||
}else if (c==195){ //umlauts
|
||||
#ifdef DEBUG
|
||||
Serial1.println("2 byte char");
|
||||
#endif
|
||||
for (uint8_t i=0;i<NUM_SCANPINS;i++){
|
||||
keypress[i]=keymatrix195[c2][i]; //copy keypress connections for current char
|
||||
waitFormatChar=false;
|
||||
keyimplemented=false; //do not count as printed key
|
||||
|
||||
} else
|
||||
{
|
||||
|
||||
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<NUM_SCANPINS;i++){
|
||||
keypress[i]=keymatrix[c][i]; //copy keypress connections for current char
|
||||
}
|
||||
}else if (c==195){ //umlauts
|
||||
#ifdef DEBUG
|
||||
Serial1.println("2 byte char");
|
||||
#endif
|
||||
for (uint8_t i=0;i<NUM_SCANPINS;i++){
|
||||
keypress[i]=keymatrix195[c2][i]; //copy keypress connections for current char
|
||||
}
|
||||
}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 (c2==178){ // ²
|
||||
keypress[1]=32; keypress[4]=8; //CODE + X
|
||||
}else if (c2==179){ // ³
|
||||
keypress[1]=32; keypress[4]=16; //CODE + V
|
||||
}
|
||||
}else if(c>=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
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue