Code:
#include <fxcg/display.h>
#include <fxcg/keyboard.h>
#include <fxcg/rtc.h>
#include <fxcg/system.h>
#include <stdlib.h>
#include <string.h>
#define MENU_MATRIX_CODE 0x0409
#define EXE_MATRIX_CODE 0x0302
int flashState = 0;
void flashRealIcon(void) {
flashState = !flashState;
DefineStatusAreaFlags(flashState ? 4 : 5, SAF_SETUP_COMPLEX_MODE, NULL, NULL);
DisplayStatusArea();
Bdisp_PutDisp_DD();
}
void drawRightAligned(int y, const char* text) {
int len = strlen(text);
int px = 384 - len * 12;
PrintXY(px / 6, y, text, TEXT_MODE_NORMAL, TEXT_COLOR_WHITE);
}
void main(void) {
char *buffer = (char *)malloc(256);
buffer[0] = '\0';
int start = 0;
int cursor = 0;
char* history[8] = { NULL };
int lineCount = 0;
DrawFrame(0);
DisplayMBString((unsigned char *)buffer, start, cursor, 1, 1);
Bdisp_PutDisp_DD();
char timerID = Timer_Install(0, flashRealIcon, 780);
if (timerID != -1)
Timer_Start(timerID);
while (1) {
int key = 0;
int result = GetKey(&key);
int col = (key >> 8) & 0xFF;
int row = key & 0xFF;
unsigned short matrixCode = (col << 8) | row;
if (matrixCode == MENU_MATRIX_CODE) {
break;
}
if (matrixCode == EXE_MATRIX_CODE) {
if (lineCount < 8 && strlen(buffer) > 0) {
history[lineCount] = strdup(buffer);
lineCount++;
buffer[0] = '\0';
cursor = 0;
start = 0;
}
} else if (result == 1 && key < 30000) {
cursor = EditMBStringChar((unsigned char *)buffer, 256, cursor, key);
} else {
EditMBStringCtrl((unsigned char *)buffer, 256, &start, &cursor, &key, 1, 1 + lineCount);
}
Bdisp_AllClr_VRAM();
DrawFrame(0);
for (int i = 0; i < lineCount; i++) {
drawRightAligned(1 + i, history[i]);
}
DisplayMBString((unsigned char *)buffer, start, cursor, 1, 1 + lineCount);
DisplayStatusArea();
Bdisp_PutDisp_DD();
}
for (int i = 0; i < lineCount; i++) free(history[i]);
free(buffer);
Bdisp_AllClr_VRAM();
Bdisp_PutDisp_DD();
}
This is code has Real flashing and a black frame and has basic text input however what I am trying to achieve is that by clicking EXE it re prints what I originally wrote in my first line back down one line below on the rightmost side however upon clicking EXE nothing happens.
Any help/guidance on the issue appreciated.