Ejemplo n.º 1
0
void GUI_DrawLabelHelper(u16 obj_x, u16 obj_y, u16 obj_w, u16 obj_h, const char *str,
        const struct LabelDesc *desc, u8 is_selected)
{
    u16 txt_w, txt_h;
    u16 txt_x, txt_y;
    u16 offset = (LCD_DEPTH > 1 && desc->font==NARROW_FONT.font) ? 1 : 0;
    LCD_SetFont(desc->font);
    LCD_GetStringDimensions((const u8 *)str, &txt_w, &txt_h); txt_w++;
    if (obj_w == 0)
        obj_w = txt_w;
    if (obj_h == 0)
        obj_h = txt_h;
    if (offset && obj_y >= offset) {
        obj_y -= offset;
    }
    if (desc->style == LABEL_BOX) {
        // draw round rect for the textsel widget when it is pressable
        if (is_selected) {
            LCD_FillRoundRect(obj_x, obj_y, obj_w, obj_h , 3, 1);
        }  else {
            GUI_DrawBackground(obj_x, obj_y, obj_w, obj_h);
            LCD_DrawRoundRect(obj_x, obj_y, obj_w, obj_h , 3,  1);
        }
    }
    else if (desc->style == LABEL_FILL) {
        LCD_FillRect(obj_x, obj_y, obj_w, obj_h, desc->fill_color);
    } else {
        GUI_DrawBackground(obj_x, obj_y, obj_w, obj_h);
    }
    if (desc->fill_color != desc->outline_color) {
        LCD_DrawRect(obj_x, obj_y, obj_w, obj_h, desc->outline_color);
        obj_x+=2; obj_w-=4;
    }

    if (desc->style == LABEL_RIGHT) {
        txt_x = obj_x + obj_w - txt_w;
    } else if (obj_w > txt_w && !(desc->style == LABEL_LEFT)) {
        txt_x = obj_x+1 + (obj_w - txt_w + 1) / 2;
    } else {
        txt_x = obj_x+1;
    }
    txt_y = obj_y + offset + (obj_h - txt_h + 1) / 2;

    if (desc->style != LABEL_FILL && is_selected) {
        LCD_SetFontColor(~desc->font_color);
    } else {
        LCD_SetFontColor(desc->font_color);
    }
    LCD_PrintStringXY(txt_x, txt_y, str);
}
Ejemplo n.º 2
0
static void kb_draw_key(struct guiBox *box, char c, u8 pressed)
{
    u16 w, h;
    u16 bg_color;
    u16 fg_color;
    char ch[2];
    const char *str = "";
    if ( c == '\x06') { //DONE
        str = "DONE";
        if (pressed) {
            bg_color = Display.keyboard.fg_key3;
            fg_color = Display.keyboard.bg_key3;
        } else {
            bg_color = Display.keyboard.bg_key3;
            fg_color = Display.keyboard.fg_key3;
        }
    } else if (c < ' ') { //CAPS, DEL, NUMPAD
        if      (c == '\x09') str = caps_str;
        else if (c == '\x08') str = del_str;
        else if (c == '\x01') str = mix_str;
        else if (c == '\x02') str = char_str;

        if (pressed) {
            bg_color = Display.keyboard.fg_key2;
            fg_color = Display.keyboard.bg_key2;
        } else {
            bg_color = Display.keyboard.bg_key2;
            fg_color = Display.keyboard.fg_key2;
        }
    } else {
        if (c == ' ') {
            str = space_str;
        } else {
            ch[0] = c;
            ch[1] = 0;
            str = ch;
        }
        if (pressed) {
            bg_color = Display.keyboard.fg_key1;
            fg_color = Display.keyboard.bg_key1;
        } else {
            bg_color = Display.keyboard.bg_key1;
            fg_color = Display.keyboard.fg_key1;
        }
    }
    /*
    printf("(%dx%dx%dx%d)", box->x, box->y, box->width, box->height);
    if(coords1)
        printf(" coords1: %dx%d", coords1->x, coords1->y);
    if(coords2)
        printf(" coords2: %dx%d", coords2->x, coords2->y);
    printf(" Draw: %d\n", draw);
    */
    LCD_SetFont(Display.keyboard.font);
    _draw_key_bg(box, pressed, bg_color);
    LCD_GetStringDimensions((const u8 *)str, &w, &h);
    LCD_SetXY(box->x + (box->width - w) / 2, box->y + (box->height - h) / 2);
    LCD_SetFontColor(fg_color);
    LCD_PrintString((const char *)str);
}
Ejemplo n.º 3
0
void GUI_DrawLabelHelper(u16 obj_x, u16 obj_y, u16 obj_w, u16 obj_h, const char *str,
        const struct LabelDesc *desc, u8 is_selected)
{
    u16 txt_w, txt_h;
    u16 txt_x, txt_y;
    // This is used to align text vertically
    u16 offset = (desc->font==NARROW_FONT.font) ? 1 : 0;
    LCD_SetFont(desc->font);
    LCD_GetStringDimensions((const u8 *)str, &txt_w, &txt_h); txt_w++;
    if (obj_w == 0)
        obj_w = txt_w;
    if (obj_h == 0)
        obj_h = txt_h;
    if (desc->style == LABEL_LISTBOX) {
        LCD_FillRect(obj_x, obj_y, obj_w, obj_h, is_selected ? Display.listbox.fg_color : Display.listbox.bg_color);
    } else if (desc->style == LABEL_FILL) {
        LCD_FillRect(obj_x, obj_y, obj_w, obj_h, desc->fill_color);
    } else {
        GUI_DrawBackground(obj_x, obj_y, obj_w, obj_h);
    }
    if (desc->style != LABEL_LISTBOX && desc->fill_color != desc->outline_color) {
        LCD_DrawRect(obj_x, obj_y, obj_w, obj_h, desc->outline_color);
        obj_x+=2; obj_w-=4;
    }

    if (desc->style == LABEL_RIGHT) {
        txt_x = obj_x + obj_w - txt_w;
    } else if (obj_w > txt_w && !(desc->style == LABEL_LEFT)) {
        txt_x = obj_x+1 + (obj_w - txt_w + 1) / 2;
    } else {
        txt_x = obj_x+1;
    }
    txt_y = obj_y + offset + (obj_h - txt_h + 1) / 2;

    if (desc->style == LABEL_LISTBOX) {
        LCD_SetFontColor(is_selected ? Display.listbox.fg_select : Display.listbox.bg_select);
    } else {
        if (desc->style != LABEL_FILL && is_selected) {
            LCD_SetFontColor(~desc->font_color);
        } else {
            LCD_SetFontColor(desc->font_color);
        }
    }
    LCD_PrintStringXY(txt_x, txt_y, str);
}
Ejemplo n.º 4
0
void TestFontRender(CuTest* t)
{
    memset(FontNames, 0, sizeof(FontNames));
    int idx = FONT_GetFromString("15normal");
    LCD_Clear(0);
    LCD_SetFont(idx);
    LCD_SetFontColor(0xF0);
    LCD_PrintStringXY(0, 0, "the quick brown fox jumps over the lazy dog");
    LCD_PrintStringXY(5, 20, "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG");
    LCD_PrintStringXY(15, 40, "0123456789)!@#$%^&*(");

    AssertScreenshot(t, "font");
}
Ejemplo n.º 5
0
int main() {
    PWR_Init();
    CLOCK_Init();
    UART_Initialize();
    if(PWR_CheckPowerSwitch()) PWR_Shutdown();
#if SPI_BOOTLOADER
    Initialize_ButtonMatrix();
    SPIFlash_Init(); //This must come before LCD_Init() for 7e
    SPI_FlashBlockWriteEnable(1); //Enable writing to all banks of SPIFlash
    LCD_Init();
    LCD_Clear(0x0000);
    BACKLIGHT_Init();
    BACKLIGHT_Brightness(5);
    LCD_SetFont(0);
    LCD_SetFontColor(0xffff);
    dump_bootloader(0);
#else
    dump_bootloader(1);
#endif
}
Ejemplo n.º 6
0
static void _kb_draw_text(const char *str)
{
    u16 w, h;

    LCD_SetFont(Display.keyboard.font);
    LCD_GetCharDimensions('A', &w, &h);
    LCD_FillRoundRect(TEXTBOX_X_OFFSET, TEXTBOX_Y_OFFSET,
                      LCD_WIDTH - 2 * TEXTBOX_X_OFFSET,
                      TEXTBOX_HEIGHT,
                      TEXTBOX_ROUND,
                      TEXTBOX_BG_COLOR);  // clear the backgroup firstly
    LCD_DrawRoundRect(TEXTBOX_X_OFFSET, TEXTBOX_Y_OFFSET,
                      LCD_WIDTH - 2 * TEXTBOX_X_OFFSET,
                      TEXTBOX_HEIGHT,
                      TEXTBOX_ROUND,
                      TEXTBOX_OUTLINE);
    LCD_SetXY(TEXTBOX_X_OFFSET + 2, (TEXTBOX_HEIGHT - h) / 2 + TEXTBOX_Y_OFFSET);
    LCD_SetFontColor(TEXTBOX_COLOR);
    LCD_PrintString(str);
}
Ejemplo n.º 7
0
void GUI_DrawDialog(struct guiObject *obj)
{
    struct guiBox *box = &obj->box;
    struct guiDialog *dialog = (struct guiDialog *)obj;
    if (dialog->txtbox.height == 0) {
        _draw_dialog_box(box, dialog->txtbox.x, dialog->title);
    } else if(dialog->txtbox.width) {
        // NOTE: We assume all redraw events after the 1st are incremental!
        GUI_DialogDrawBackground(dialog->txtbox.x, dialog->txtbox.y,
                                 dialog->txtbox.width, dialog->txtbox.height);
    }
    const char *str = dialog->string_cb
                         ? dialog->string_cb(obj, dialog->cbData)
                         : (const char *)dialog->cbData;
    int button_height = GUI_ButtonHeight(DIALOG_BUTTON);
    LCD_SetFont(DIALOGBODY_FONT.font);
    LCD_SetFontColor(DIALOGBODY_FONT.font_color);
    LCD_GetStringDimensions((const u8 *)str, &dialog->txtbox.width, &dialog->txtbox.height);
    dialog->txtbox.y = box->y + DIALOG_HEADER_Y +
        (box->height - dialog->txtbox.height - DIALOG_HEADER_Y - button_height) / 2;
    LCD_PrintStringXY(dialog->txtbox.x, dialog->txtbox.y, str);
}
Ejemplo n.º 8
0
int main() {

    Init();
#ifndef MODULAR
    //Banner();
#endif
    if(PWR_CheckPowerSwitch()) PWR_Shutdown();

    LCD_Clear(0x0000);
#ifdef TEST_ADC
    ADC_ScanChannels(); while(1);
#endif
    u32 buttons = ScanButtons();
    if(CHAN_ButtonIsPressed(buttons, BUT_ENTER) || !FS_Mount(NULL, NULL)) {
        LCD_DrawUSBLogo(LCD_WIDTH, LCD_HEIGHT);
        USB_Connect();
        LCD_Clear(0x0000);
        FS_Mount(NULL, NULL);
    }

    CONFIG_LoadTx();
    SPI_ProtoInit();
    CONFIG_ReadDisplay();
    CONFIG_ReadModel(CONFIG_GetCurrentModel());
    CONFIG_ReadLang(Transmitter.language);

    BACKLIGHT_Brightness(Transmitter.backlight);
    LCD_Contrast(Transmitter.contrast);
    LCD_SetFont(DEFAULT_FONT.font);
    LCD_SetFontColor(DEFAULT_FONT.font_color);

#if !HAS_EXTENDED_AUDIO
    // If Extended Audio is present, move startup msg to Splash page to allow additional audio hardware initialization time
    MUSIC_Play(MUSIC_STARTUP);
#else
    if (Transmitter.splash_delay < 5)
        MUSIC_Play(MUSIC_STARTUP); // if no splash page startup msg is used force playing here
#endif
    GUI_HandleButtons(1);

    MIXER_Init();
    PAGE_Init();

    CLOCK_StartWatchdog();

#if HAS_DATALOG
    DATALOG_Init();
#endif

    priority_ready = 0;
    CLOCK_SetMsecCallback(LOW_PRIORITY, LOW_PRIORITY_MSEC);
    CLOCK_SetMsecCallback(MEDIUM_PRIORITY, MEDIUM_PRIORITY_MSEC);

    // We need to wait until we've actually measured the ADC before proceeding
    while(! (priority_ready & (1 << LOW_PRIORITY)))
        ;

    //Only do this after we've initialized all channel data so the saftey works
    PROTOCOL_InitModules();
    GUI_DrawScreen();

#ifdef HAS_EVENT_LOOP
    start_event_loop();
#else
    while(1) {
        if(priority_ready) {
            EventLoop();
        }
        //This does not appear to have any impact on power
        //and has been disabled in common/devo/power.c
        //but it helps a huge amount for the emulator
        PWR_Sleep();
    }
#endif
}
Ejemplo n.º 9
0
int main() {
    
    Init();
#ifndef MODULAR
    //Banner();
#endif
    if(PWR_CheckPowerSwitch()) PWR_Shutdown();

    LCD_Clear(0x0000);
#ifdef TEST_ADC
    ADC_ScanChannels(); while(1);
#endif
    u32 buttons = ScanButtons();
    if(CHAN_ButtonIsPressed(buttons, BUT_ENTER) || !FS_Mount(NULL, NULL)) {
        LCD_DrawUSBLogo(LCD_WIDTH, LCD_HEIGHT);
        USB_Connect();
        LCD_Clear(0x0000);
        FS_Mount(NULL, NULL);
    }
    
    CONFIG_LoadTx();
    SPI_ProtoInit();
    CONFIG_ReadDisplay();
    CONFIG_ReadModel(CONFIG_GetCurrentModel());
    CONFIG_ReadLang(Transmitter.language);

    BACKLIGHT_Brightness(Transmitter.brightness);
    LCD_Contrast(Transmitter.contrast);
    LCD_SetFont(DEFAULT_FONT.font);
    LCD_SetFontColor(DEFAULT_FONT.font_color);

    MUSIC_Play(MUSIC_STARTUP);
    GUI_HandleButtons(1);

    MIXER_Init();
    PAGE_Init();
    
    CLOCK_StartWatchdog();

#if DATALOG_ENABLED
    DATALOG_Init();
#endif

    priority_ready = 0;
    CLOCK_SetMsecCallback(LOW_PRIORITY, LOW_PRIORITY_MSEC);
    CLOCK_SetMsecCallback(MEDIUM_PRIORITY, MEDIUM_PRIORITY_MSEC);

    // We need to wait until we've actually measured the ADC before proceeding
    while(! (priority_ready & (1 << LOW_PRIORITY)))
        ;

    //Only do this after we've initialized all channel data so the saftey works
    PROTOCOL_Init(0);
    GUI_DrawScreen();

#ifdef HAS_EVENT_LOOP
    start_event_loop();
#else
    while(1) {
        if(priority_ready) {
            EventLoop();
        }
        //PWR_Sleep();  //This does not appear to have any impact on power
    }
#endif
}
Ejemplo n.º 10
0
void GUI_DrawLabelHelper(u16 obj_x, u16 obj_y, u16 obj_w, u16 obj_h, const char *str,
        const struct LabelDesc *desc, u8 is_selected)
{
    u16 txt_w, txt_h;
    u16 txt_x, txt_y;
    u16 offset = (LCD_DEPTH > 1 && desc->font==NARROW_FONT.font) ? 1 : 0;
    LCD_SetFont(desc->font);
    LCD_GetStringDimensions((const u8 *)str, &txt_w, &txt_h); txt_w++;
    if (obj_w == 0)
        obj_w = txt_w;
    if (obj_h == 0)
        obj_h = txt_h;
    if (offset && obj_y >= offset) {
        obj_y -= offset;
    }
    if (desc->style != LABEL_TRANSPARENT)
    {
        GUI_DrawBackground(obj_x, obj_y, obj_w, obj_h);
    }
    if (desc->style == LABEL_BOX || desc->style == LABEL_BRACKET || desc->style == LABEL_SQUAREBOX) {
        // draw round rect for the textsel widget when it is pressable
        if (is_selected) {
            if (desc->style == LABEL_SQUAREBOX ||obj_w < 5)
                LCD_FillRect(obj_x, obj_y, obj_w, obj_h , 1);
            else
                LCD_FillRoundRect(obj_x, obj_y, obj_w, obj_h , 3, 1);
        }  else {
            if (desc->style == LABEL_SQUAREBOX)
                if (desc->fill_color == 0)
                    LCD_DrawRect(obj_x, obj_y, obj_w, obj_h, 1);
                else
                    LCD_FillRect(obj_x, obj_y, obj_w, obj_h, desc->fill_color);
            else if (desc->style == LABEL_BRACKET) {
                struct pos { int i1; int i2; int i3; int i4;};
                struct { union { int p[4]; struct pos pos;} u;} x[2], y[2];
                //int x[2][4];
                //int y[2][4];
                if (obj_h > 2 * obj_w) {
                    x[0].u.pos = (struct pos){ 0, 2, obj_w -3, obj_w -1};
                    y[0].u.pos = (struct pos){ 2, 0, 0, 2};
                    x[1].u.pos = x[0].u.pos;
                    y[1].u.pos = (struct pos){ obj_h -3, obj_h -1, obj_h -1, obj_h -3};
                } else {
                    x[0].u.pos = (struct pos){ 2, 0, 0, 2};
                    y[0].u.pos = (struct pos){ 0, 2, obj_h -3, obj_h -1};
                    x[1].u.pos = (struct pos){ obj_w -3, obj_w -1, obj_w -1,  obj_w -3};
                    y[1].u.pos = y[0].u.pos;
                }
                for(int oc = 0; oc < 2; oc++) {
                    for(int i = 0; i < 3; i++) {
                        LCD_DrawLine(obj_x + x[oc].u.p[i], obj_y+y[oc].u.p[i], obj_x+x[oc].u.p[i+1], obj_y + y[oc].u.p[i+1], 1);
                    }
                }
            } else
                LCD_DrawRoundRect(obj_x, obj_y, obj_w, obj_h , 3,  1);
        }
    }
    else if (desc->style == LABEL_FILL) {
        LCD_FillRect(obj_x, obj_y, obj_w, obj_h, desc->fill_color);
    }
    else if (desc->style == LABEL_INVERTED || is_selected) {
        LCD_FillRect(obj_x, obj_y, obj_w, obj_h, 0xffff);
    }
    if (desc->style == LABEL_TRANSPARENT || (LCD_DEPTH > 1 && desc->fill_color != desc->outline_color)) {
        LCD_DrawRect(obj_x, obj_y, obj_w, obj_h, desc->outline_color);
        obj_x+=2; obj_w-=4;
    }

    if (desc->style == LABEL_RIGHT) {
        txt_x = obj_x + obj_w - txt_w;
    } else if (obj_w > txt_w && !(desc->style == LABEL_LEFT || desc->style == LABEL_NO_BOX
                                                            || desc->style == LABEL_UNDERLINE)) {
        txt_x = obj_x+1 + (obj_w - txt_w + 1) / 2;
    } else {
        txt_x = obj_x+1;
    }
    txt_y = obj_y + offset + (obj_h - txt_h + 1) / 2;

    if (desc->style == LABEL_UNDERLINE) {
        LCD_DrawFastHLine(--txt_x, txt_y + txt_h - 1, obj_w, 1);
    }
    if (desc->style == LABEL_BLINK) {
        blink_fontcolor = ~blink_fontcolor;
        LCD_SetFontColor(blink_fontcolor);
    } else if (desc->style == LABEL_INVERTED || (desc->style != LABEL_FILL && is_selected)) {
        LCD_SetFontColor(~desc->font_color);
    } else {
        LCD_SetFontColor(desc->font_color);
    }
    LCD_PrintStringXY(txt_x, txt_y, str);
}
Ejemplo n.º 11
0
int main() {

    Init();
#ifndef ENABLE_MODULAR
    //Banner();
#endif
    if(PWR_CheckPowerSwitch()) PWR_Shutdown();

    LCD_Clear(0x0000);
#ifdef TEST_ADC
    ADC_ScanChannels(); while(1);
#endif
    u32 buttons = ScanButtons();
    if (CHAN_ButtonIsPressed(buttons, BUT_ENTER) || !FS_Init()) {
        LCD_DrawUSBLogo(LCD_WIDTH, LCD_HEIGHT);
        USB_Connect();
        LCD_Clear(0x0000);
        FS_Init();
    }

    CONFIG_LoadTx();
    SPI_ProtoInit();
    CONFIG_ReadDisplay();
    CONFIG_ReadModel(CONFIG_GetCurrentModel());
    CONFIG_ReadLang(Transmitter.language);

    BACKLIGHT_Brightness(Transmitter.backlight);
    LCD_Contrast(Transmitter.contrast);
    LCD_SetFont(DEFAULT_FONT.font);
    LCD_SetFontColor(DEFAULT_FONT.font_color);

    GUI_HandleButtons(1);

    MIXER_Init();
    PAGE_Init();

    CLOCK_StartWatchdog();

#if HAS_DATALOG
    DATALOG_Init();
#endif

    priority_ready = 0;
    CLOCK_SetMsecCallback(LOW_PRIORITY, LOW_PRIORITY_MSEC);
    CLOCK_SetMsecCallback(MEDIUM_PRIORITY, MEDIUM_PRIORITY_MSEC);

    // We need to wait until we've actually measured the ADC before proceeding
    while(! (priority_ready & (1 << LOW_PRIORITY)))
        PWR_Sleep();

    //Only do this after we've initialized all channel data so the saftey works
    PROTOCOL_InitModules();
    GUI_DrawScreen();

    // Add startup delay to make sure audio player is initialized
    // AUDIO_Init() has already been called by CONFIG_ReadModel()
#if HAS_EXTENDED_AUDIO
    audio_queue_time = CLOCK_getms() + 1500;
    num_audio=1;
    next_audio=1;
#if (LCD_WIDTH == 480) || (LCD_WIDTH == 320)
    if(Display.background.drawn_background)
        while(CLOCK_getms() < audio_queue_time - 1200);
#endif
    AUDIO_SetVolume(); // Initial setting of voice volume
#endif

    MUSIC_Play(MUSIC_STARTUP);

#ifdef HAS_EVENT_LOOP
    start_event_loop();
#else
    while(1) {
        if(priority_ready) {
            EventLoop();
        }
        //This does not appear to have any impact on power
        //and has been disabled in common/devo/power.c
        //but it helps a huge amount for the emulator
        PWR_Sleep();
    }
#endif
}