update gui
This commit is contained in:
parent
f847cd8869
commit
b18969fef0
BIN
qt_gui.png
BIN
qt_gui.png
Binary file not shown.
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 57 KiB |
@ -19,7 +19,7 @@ ApplicationWindow
|
||||
Rectangle{
|
||||
width: 100
|
||||
height: 25
|
||||
color: "red"
|
||||
color: "#ff9494"
|
||||
Text {text: "Quit"}
|
||||
MouseArea {
|
||||
onClicked: Qt.quit()
|
||||
@ -56,10 +56,21 @@ ApplicationWindow
|
||||
id: key_key;
|
||||
width: 100;
|
||||
height: 100;
|
||||
color: "gray"
|
||||
color: getBackgroundColor(parent.objectName, index)
|
||||
border { width: 1; color: "black" }
|
||||
Text {
|
||||
text: {getText(parent.parent.objectName, index)}
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
font.pointSize: 16
|
||||
color: "gray"
|
||||
text: {getShiftedText(parent.parent.objectName, index) + "<br><br>"}
|
||||
textFormat: Text.RichText
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
Text {
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
font.pointSize: 24
|
||||
text: {"<br>" + getText(parent.parent.objectName, index) + "<br>"}
|
||||
textFormat: Text.RichText
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
MouseArea {
|
||||
@ -74,13 +85,37 @@ ApplicationWindow
|
||||
|
||||
function getText(row, col) {
|
||||
var keys = [
|
||||
["Shift", "x<->y", "+/-", "C"],
|
||||
["7", "8", "9", "/"],
|
||||
["4", "5", "6", "*"],
|
||||
["1", "2", "3", "-"],
|
||||
["0", ".", "Enter", "+"]
|
||||
["Shift", "x ⇄ y", "±", "←"],
|
||||
["7", "8", "9", "÷"],
|
||||
["4", "5", "6", "×"],
|
||||
["1", "2", "3", "-"],
|
||||
["0", ".", "Enter", "+"]
|
||||
]
|
||||
|
||||
return keys[row][col]
|
||||
return "<b>" + keys[row][col] + "</b>"
|
||||
}
|
||||
|
||||
function getShiftedText(row, col) {
|
||||
var shifted_keys = [
|
||||
["Shift", "1/x", " √<span style=\"text-decoration: overline\">x</span> ", "CL<i>x</i>"],
|
||||
["y<sup>x</sup> ", "ln(x)", "log(x)", ""],
|
||||
["", "e<sup>x</sup>", "10<sup>x</sup>", ""],
|
||||
["", "", "", ""],
|
||||
["off", "", "", ""]
|
||||
]
|
||||
|
||||
return "<small>" + shifted_keys[row][col] + "</small>"
|
||||
}
|
||||
|
||||
function getBackgroundColor(row, col) {
|
||||
var background_color = [
|
||||
["white", "white", "white", "#ff9494"],
|
||||
["#eeeeee", "#eeeeee", "#eeeeee", "white"],
|
||||
["#eeeeee", "#eeeeee", "#eeeeee", "white"],
|
||||
["#eeeeee", "#eeeeee", "#eeeeee", "white"],
|
||||
["#eeeeee", "#eeeeee", "white", "white"]
|
||||
]
|
||||
|
||||
return background_color[row][col]
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,11 @@ void LCD_Clear(void);
|
||||
void LCD_GoTo(uint8_t row, uint8_t col);
|
||||
|
||||
void LCD_OutString(__xdata const char* string, uint8_t max_chars);
|
||||
#ifdef DESKTOP
|
||||
void LCD_OutString_Initial(__xdata const char* string, uint8_t max_chars);
|
||||
#else
|
||||
#define LCD_OutString_Initial(a, b) LCD_OutString(a, b)
|
||||
#endif
|
||||
short TERMIO_PutChar(unsigned char letter);
|
||||
void LCD_OutNibble(uint8_t x);
|
||||
void LCD_ClearToEnd(uint8_t curr_row);
|
||||
|
@ -15,6 +15,8 @@
|
||||
static uint8_t lcd_row, lcd_col;
|
||||
static char lcd_buf[MAX_ROWS][MAX_CHARS_PER_LINE];
|
||||
|
||||
static char enable_checks = 1;
|
||||
|
||||
const char* get_lcd_buf(void){
|
||||
return &lcd_buf[0][0];
|
||||
}
|
||||
@ -71,6 +73,12 @@ void LCD_OutString(const char *string, uint8_t max_chars) {
|
||||
}
|
||||
}
|
||||
|
||||
void LCD_OutString_Initial(const char *string, uint8_t max_chars) {
|
||||
enable_checks = 0;
|
||||
LCD_OutString(string, max_chars);
|
||||
enable_checks = 1;
|
||||
}
|
||||
|
||||
static int is_valid_character(char letter){
|
||||
if (isdigit(letter)){
|
||||
return 1;
|
||||
@ -78,6 +86,8 @@ static int is_valid_character(char letter){
|
||||
return 1;
|
||||
} else if(letter == '.' || letter == ' ' || letter == '-'){
|
||||
return 1;
|
||||
} else if(letter == '^'){
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -94,7 +104,7 @@ short TERMIO_PutChar(unsigned char letter) {
|
||||
}
|
||||
}
|
||||
//warn if unknown character
|
||||
if (!is_valid_character(letter)) {
|
||||
if (!is_valid_character(letter) && enable_checks) {
|
||||
printf("\nerror @%d,%d, invalid character %d\n",
|
||||
lcd_row, lcd_col, letter);
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ int main()
|
||||
ExpBuf[0] = 0;
|
||||
ExpBuf[1] = 0;
|
||||
|
||||
LCD_OutString(VER_STR, 32);
|
||||
LCD_OutString_Initial(VER_STR, 32);
|
||||
#ifdef DESKTOP
|
||||
LcdAvailable.release();
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user