Exemplo n.º 1
0
void PAGE_ShowLowBattDialog()
{
    PAGE_ShowWarning(_tr("Low Battery"),
         _tr("Critical battery level detected.\n"
             "Settings have been saved.\n"
             "Any future configuration settings\n"
             "will NOT be saved.\n\n"
             "Change batteries now!"));
}
Exemplo n.º 2
0
void PAGE_ShowModuleDialog(const char **missing)
{
    if (dialog)
        return;
    dialogcrc = 0;
    sprintf(tempstring, "%s", _tr("Missing Modules:\n"));
    for(int i = 0; i < TX_MODULE_LAST; i++) {
       if(missing[i]) {
           sprintf(tempstring+strlen(tempstring), "%s\n", missing[i]);
       }
    } 
    current_selected_obj = 0;
    PAGE_ShowWarning(_tr("Module Error"), tempstring);
}
Exemplo n.º 3
0
void PAGE_ShowModuleDialog(const char **missing)
{
    if (dialog)
        return;
    dialogcrc = 0;
    int count = 0;
    sprintf(tempstring, "%s", _tr("Missing Modules:\n"));
    if(missing[MULTIMOD]) {
        sprintf(tempstring+strlen(tempstring), "%s", missing[MULTIMOD]);
    } else {
        for(int i = 0; i < MULTIMOD; i++) {
           if(missing[i]) {
               if(! count) {
                   sprintf(tempstring+strlen(tempstring), " %s", missing[i]);
               } else if(count == 1) {
                   sprintf(tempstring+strlen(tempstring), " ...");
               }
               count++;
           }
        }
    } 
    PAGE_ShowWarning(NULL, tempstring);
}
Exemplo n.º 4
0
void PROTOCOL_Load(int no_dlg)
{
    (void)no_dlg;
#ifdef MODULAR
    if(! PROTOCOL_HasModule(Model.protocol)) {
        *loaded_protocol = 0;
        return;
    }
    if(*loaded_protocol == Model.protocol)
        return;
    char file[25];
    strcpy(file, "protocol/");
    #define PROTODEF(proto, module, map, cmd, name) case proto: strcat(file,name); break;
    switch(Model.protocol) {
        #include "protocol.h"
        default: *loaded_protocol = 0; return;
    }
    #undef PROTODEF
    file[17] = '\0'; //truncate filename to 8 characters
    strcat(file, ".mod");
    FILE *fh;
    //We close the current font because on the dveo8 we reuse
    //the font filehandle to read the protocol.
    //Thatis necessary because we need to be able to load the
    //protocol while an ini file is open, and we don't want to
    //waste the RAM for an extra filehandle
    u8 old_font = LCD_SetFont(0);
    finit(&FontFAT, ""); //In case no fonts are loaded yet
    fh = fopen2(&FontFAT, file, "r");
    //printf("Loading %s: %08lx\n", file, fh);
    if(! fh) {
        if(! no_dlg) {
            sprintf(tempstring, "Misisng protocol:\n%s", file);
            PAGE_ShowWarning(NULL, tempstring);
        }
        LCD_SetFont(old_font);
        return;
    }
    setbuf(fh, 0);
    int size = 0;
    unsigned char buf[256];
    int len;
    char *ptr = (char *)loaded_protocol;
    while(size < 4096) {
        len = fread(buf, 1, 256, fh);
        if(len) {
            memcpy(ptr, buf, len);
            ptr += len;
        }
        size += len;
        if (len != 256)
            break;
    }
    fclose(fh);
    LCD_SetFont(old_font);
    if ((unsigned long)&_data_loadaddr != *loaded_protocol) {
        if(! no_dlg) {
            sprintf(tempstring, "Protocol Mismatch:\n%08x\n%08x", (unsigned long)&_data_loadaddr, *loaded_protocol);
            PAGE_ShowWarning(NULL, tempstring);
        }
        *loaded_protocol = 0;
        return;
    }
    //printf("Updated %d (%d) bytes: Data: %08lx %08lx %08lx\n", size, len, *loaded_protocol, *(loaded_protocol+1), *(loaded_protocol+2));
    //We use the same file for multiple protocols, so we need to manually set this here
    *loaded_protocol = Model.protocol;
#else
    if(! PROTOCOL_HasModule(Model.protocol)) {
        PROTO_Cmds = NULL;
        printf("Module is not defined!\n");
        return;
    }
    #define PROTODEF(proto, module, map, cmd, name) case proto: PROTO_Cmds = cmd; break;
    switch(Model.protocol) {
        #include "protocol.h"
        default: PROTO_Cmds = NULL;
    }
    #undef PROTODEF
#endif
    PROTOCOL_SetSwitch(get_module(Model.protocol));
}
Exemplo n.º 5
0
void PAGE_ShowInvalidModule()
{
    PAGE_ShowWarning(NULL, _tr("Bad/missing\nprotocol modules!"));
}
Exemplo n.º 6
0
void PAGE_ShowLowBattDialog()
{
    PAGE_ShowWarning(NULL, _tr("Battery too low,\ncan't save!"));
}
Exemplo n.º 7
0
void PROTOCOL_Load(int no_dlg)
{
    (void)no_dlg;
#ifdef ENABLE_MODULAR
    FATFS ModuleFAT;
    FILE *fh;

    if(! PROTOCOL_HasModule(Model.protocol)) {
        *loaded_protocol = 0;
        return;
    }
    if(*loaded_protocol == Model.protocol)
        return;
    char file[25];
    strcpy(file, "protocol/");

    if (Model.protocol > PROTOCOL_COUNT)
    {
        *loaded_protocol = 0;
        return;
    }
    else
    {
        strcat(file, Protocols[Model.protocol].name);
    }
    file[17] = '\0'; //truncate filename to 8 characters
    strcat(file, ".mod");

    memset(&ModuleFAT, 0, sizeof(ModuleFAT));
    finit(&ModuleFAT, "protocol");
    fh = fopen2(&ModuleFAT, file, "r");
    //printf("Loading %s: %08lx\n", file, fh);
    if(! fh) {
        if(! no_dlg) {
            sprintf(tempstring, "Misisng protocol:\n%s", file);
            PAGE_ShowWarning(NULL, tempstring);
        }
        return;
    }
    setbuf(fh, 0);
    fread(loaded_protocol, 1, 4 * 1024, fh);
    fclose(fh);
    if ((unsigned long)&_data_loadaddr != *loaded_protocol) {
        if(! no_dlg) {
            sprintf(tempstring, "Protocol Mismatch:\n%08x\n%08x", (unsigned long)&_data_loadaddr, *loaded_protocol);
            PAGE_ShowWarning(NULL, tempstring);
        }
        *loaded_protocol = 0;
        return;
    }
    //printf("Updated %d (%d) bytes: Data: %08lx %08lx %08lx\n", size, len, *loaded_protocol, *(loaded_protocol+1), *(loaded_protocol+2));
    //We use the same file for multiple protocols, so we need to manually set this here
    *loaded_protocol = Model.protocol;
#else
    if(! PROTOCOL_HasModule(Model.protocol)) {
        PROTO_Cmds = NULL;
        printf("Module is not defined!\n");
        return;
    }
    PROTO_Cmds = Protocols[Model.protocol].cmd;
#endif
    PROTOCOL_SetSwitch(get_module(Model.protocol));
    if (PROTOCOL_GetTelemetryState() != PROTO_TELEM_UNSUPPORTED) {
        memset(&Telemetry, 0, sizeof(Telemetry));
        TELEMETRY_SetType(PROTOCOL_GetTelemetryType());
    }

    CurrentProtocolChannelMap = PROTOCOL_GetChannelMap();
}