Пример #1
0
void Controller::event_audioxfer(const char *event,const char *value) {
    display_clear(0);
    modem_full_range = false;
    display_draw_text(0,16," Audio Transfer ",65535);
    display_draw_text(4,32,"  in progress  " ,65535);
    modem_logxfer();
    m_gui->jump_to_screen(0);
}
Пример #2
0
/**
 * Update a part of the screen
 *
 * @param item  type of item to draw
 * @param value value of the item to draw
 */
void update_item(screen_item &item,const void *value) {
  if(item.type == ITEM_TYPE_VARLABEL) {
    if(item.val1 == 255) {
      // display_draw_rectangle(0,item.val2,128,item.val2+16,BACKGROUND_COLOR); unfortunately renders badly.
      display_draw_text_center(item.val2,(char *)value,FOREGROUND_COLOR);
    } else {
      display_draw_text(item.val1,item.val2,(char *)value,FOREGROUND_COLOR);
    }

  } else
  if(item.type == ITEM_TYPE_GRAPH) {
    update_item_graph(item,value);
  } else
  if(item.type == ITEM_TYPE_HEAD) {
    update_item_head(item,value);
  } else
  if(item.type == ITEM_TYPE_VARNUM) {
    update_item_varnum(item,value);
  } else
  if(item.type == ITEM_TYPE_DELAY) {
    update_item_delay(item,value);
  } else
  if(item.type == ITEM_TYPE_BIGVARLABEL) {
    display_draw_bigtext(item.val1,item.val2,(char *)value,FOREGROUND_COLOR);
  }
}
Пример #3
0
void render_item_menu(screen_item &item, bool selected) {

  uint16_t highlight = FOREGROUND_COLOR;
  if(selected) highlight = BACKGROUND_COLOR;

  // render tick
  bool ticked = is_ticked(item.text);
  if(ticked) {
    display_draw_text(128-8,item.val2*16,"\x7F",highlight);
  }

  if((m_language == LANGUAGE_ENGLISH) || (item.kanji_image == 255)) {



    int len = strlen(item.text);
    char text[50];
    strcpy(text,item.text);

    // Search for : replace with NULL in rendering
    for(int n=0;n<len;n++) {
      if(text[n] == ':') text[n] = 0;
    }
    len = strlen(text);


    // Pad to 16 characters
    for(int n=len;n<16;n++) {
      text[n  ]=' ';
      text[n+1]=0;
    }
    if(ticked) text[15]=0;

    display_draw_text(0,item.val2*16,text,highlight);
  } else
  if(m_language == LANGUAGE_JAPANESE) {
    if(!ticked) {
      display_draw_fixedimage(0,item.val2*16,item.kanji_image,highlight);
    } else {
      display_draw_fixedimage_xlimit(0,item.val2*16,item.kanji_image,highlight,128-8);
    }
  }

}
Пример #4
0
/**
 * Displays battery level on OLED for 100 seconds,
 * updates once per second
 */
void cmd_batinfodisp(char *line) {
  for(int n=0;n<100;n++) {
    int bat = power_battery_level();
    char s[20];
    sprintf(s,"%d   ",bat);

    display_draw_text(0,0,s,0);
    delay_us(1000000);
  }
}
Пример #5
0
/**
 * Rendering of a variable number/char (single digit with
 * up/down arrows above/below it).
 *
 * @param item should be an ITEM_TYPE_VARNUM
 * @param selected if cursor should be on that particular digit
 */
void render_item_varnum(screen_item &item, bool selected) {

  // Position on screen where to draw the digit
  uint8_t x = item.val1;
  uint8_t y = item.val2;

  int len = strlen(item.text);
  int colon_pos=-1;
  // Text can be with this format:
  // "NAME:char1,char2,char..." to let user select
  // non-numeric values, we detect this below:
  for(int n=0;n<len;n++) {
    if(item.text[n] == ':') colon_pos=n;
  }

  bool nonnumeric = false;
  char selitem[10][10];
  // We have a non-numeric variable, initialize the
  // possible values (comma-separated string following ":"
  // in the item.text. For instance: "SIGN:-,+,"
  if(colon_pos != -1) {
    nonnumeric=true;

    char current[10];
    int  current_pos=0;
    int  cselitem=0;
    for(int n=colon_pos+1;n<len;n++) {

      if(item.text[n] != ',') {
        current[current_pos  ] = item.text[n];
        current[current_pos+1] = 0;
        current_pos++;
      } else {
        strcpy(selitem[cselitem],current);
        current_pos=0;
        current[0]=0;
        cselitem++;
      }
    }
  }

  // Retrieve the current value of this VARNUM
  uint8_t val = get_item_state_varnum(item.text);

  uint16_t color;
  if(selected) color = 0xcccc; else color = FOREGROUND_COLOR;
  display_draw_equtriangle(x,y,9,color);
  display_draw_equtriangle_inv(x,y+33,9,color);
  if(nonnumeric == false) {
    display_draw_number(x-4,y+9,val,1,FOREGROUND_COLOR);
  } else {
    display_draw_text(x-4,y+9,selitem[val],FOREGROUND_COLOR);
  }
}
Пример #6
0
/**
 * Render a static text label.
 *
 * @param item should be an ITEM_TYPE_LABEL
 */
void render_item_label(screen_item &item, bool selected) {

  if(m_language == LANGUAGE_ENGLISH) {
    if(item.val1 == 255) {display_draw_text_center          (item.val2,item.text,FOREGROUND_COLOR);}
                    else {display_draw_text       (item.val1,item.val2,item.text,FOREGROUND_COLOR);}
  }

  if(m_language == LANGUAGE_JAPANESE) {
    if(item.kanji_image != 255) {
			if((item.val1 != 255) && (item.val1 != 0)) {
				display_draw_fixedimage_xlimit(item.val1,item.val2,item.kanji_image,FOREGROUND_COLOR,128-item.val1);
			} else {
				// we can't center fixed images as we don't know their width, just draw at 0, full width.
				display_draw_fixedimage(0,item.val2,item.kanji_image,FOREGROUND_COLOR);
			}
    } else {
      if(item.val1 == 255) {display_draw_text_center          (item.val2,item.text,FOREGROUND_COLOR);}
                      else {display_draw_text       (item.val1,item.val2,item.text,FOREGROUND_COLOR);}
    }
  }
}
Пример #7
0
void render_item_varnum(screen_item &item, bool selected) {

  uint8_t x = item.val1;
  uint8_t y = item.val2;

  int len = strlen(item.text);
  int colon_pos=-1;
  for(int n=0;n<len;n++) {
    if(item.text[n] == ':') colon_pos=n;
  }
  
  bool nonnumeric = false;
  char selitem[10][10];
  if(colon_pos != -1) {
    nonnumeric=true;

    char current[10];
    int  current_pos=0;
    int  cselitem=0;
    for(int n=colon_pos+1;n<len;n++) {
 
      if(item.text[n] != ',') {
        current[current_pos  ] = item.text[n];
        current[current_pos+1] = 0;
        current_pos++;
      } else {
        strcpy(selitem[cselitem],current);
        current_pos=0;
        current[0]=0;
        cselitem++;
      }
    }
  }

  uint8_t val = get_item_state_varnum(item.text);

  uint16_t color;
  if(selected) color = 0xcccc; else color = FOREGROUND_COLOR;
  display_draw_equtriangle(x,y,9,color);
  display_draw_equtriangle_inv(x,y+33,9,color);
  if(nonnumeric == false) {
    display_draw_number(x-4,y+9,val,1,FOREGROUND_COLOR);
  } else {
    display_draw_text(x-4,y+9,selitem[val],FOREGROUND_COLOR);
  }
}
Пример #8
0
int main(void) {


    Geiger g;
    power_initialise();
    if(power_battery_level() < 1) {
      power_standby();
    }

    flashstorage_initialise();
    buzzer_initialise();
    realtime_initialise();
    g.initialise();

    uint8_t *private_key = ((uint8_t *) &_binary___binary_data_private_key_data_start);
    if(private_key[0] != 0) delay_us(1000);

    delay_us(10000);  // can be removed?

    #ifndef DISABLE_ACCEL
    accel_init();
    #endif

    Controller c(g);
    switch_initialise();

    // if we woke up on an alarm, we're going to be sending the system back.
    #ifndef NEVERSLEEP
    if(power_get_wakeup_source() == WAKEUP_RTC) {
      c.m_sleeping = true;
    } else {
      buzzer_nonblocking_buzz(0.05);
      display_initialise();
      const char *devicetag = flashstorage_keyval_get("DEVICETAG");
      char revtext[10];
      sprintf(revtext,"VERSION: %s ",OS100VERSION);
      display_splashscreen(devicetag,revtext);
      delay_us(3000000);
      display_clear(0);
    }
    #endif
    #ifdef NEVERSLEEP
      buzzer_nonblocking_buzz(0.05);
      display_initialise();
    #endif


    GUI m_gui(c);
    bool full = flashstorage_log_isfull();
    if((full == true) && (c.m_sleeping == false)) {
      m_gui.show_dialog("Flash Log","is full",0,0,0);
    }

    c.set_gui(m_gui);
    UserInput  u(m_gui);
    u.initialise();
    serial_initialise();
  
    int8_t utcoffsetmins_n = 0;
    const char *utcoffsetmins = flashstorage_keyval_get("UTCOFFSETMINS");
    if(utcoffsetmins != 0) {
      unsigned int c;
      sscanf(utcoffsetmins, "%u", &c);
      utcoffsetmins_n = c;

      realtime_setutcoffset_mins(utcoffsetmins_n);
    }


    // Need to refactor out stored settings
    if(c.m_sleeping == false) {   
      const char *sbright = flashstorage_keyval_get("BRIGHTNESS");
      if(sbright != 0) {
        unsigned int c;
        sscanf(sbright, "%u", &c);
        display_set_brightness(c);
      }
 
      const char *sbeep = flashstorage_keyval_get("GEIGERBEEP");
      if(sbeep != 0) {
        if(strcmp(sbeep,"true") == 0) { g.set_beep(true); tick_item("Geiger Beep",true); }
                                 else g.set_beep(false);
      }

      const char *scpmcps = flashstorage_keyval_get("CPMCPSAUTO");
      if(scpmcps != 0) {
        if(strcmp(scpmcps,"true") == 0) { c.m_cpm_cps_switch = true; tick_item("CPM/CPS Auto",true); }
      }

      const char *language = flashstorage_keyval_get("LANGUAGE");
      if(language != 0) {
        if(strcmp(language,"English" ) == 0) { m_gui.set_language(LANGUAGE_ENGLISH);  tick_item("English"  ,true); } else
        if(strcmp(language,"Japanese") == 0) { m_gui.set_language(LANGUAGE_JAPANESE); tick_item("Japanese" ,true); }
      } else {
        m_gui.set_language(LANGUAGE_ENGLISH);
        tick_item("English",true); 
      }

      const char *svrem = flashstorage_keyval_get("SVREM");
      if(strcmp(svrem,"REM") == 0) { tick_item("Roentgen",true); }
                              else { tick_item("Sievert",true);}
    }


    m_gui.jump_to_screen(1);
    m_gui.push_stack(0,1);
    for(;;) {
      if(power_battery_level() < 1) {
        power_standby();
      }

      //display_draw_text(0,110,"preupdate",0);
      c.update();
      //display_draw_text(0,110,"prerender",0);
      m_gui.render();

      //display_draw_text(0,110,"preserial",0);
      serial_eventloop();

      //display_draw_text(0,110,"preserial",0);
      // It might be a good idea to move the following code to Controller.
      // Hack to check that captouch is ok, and reset it if not.
      bool c = cap_check();
      if(c == false) {
        display_draw_text(0,90,"CAPFAIL",0);
        cap_init(); 
      }

      // Screen lock code
      uint32_t release1_time = cap_last_press(KEY_BACK);
      uint32_t   press1_time = cap_last_release(KEY_BACK);
      uint32_t release2_time = cap_last_press(KEY_SELECT);
      uint32_t   press2_time = cap_last_release(KEY_SELECT);
      uint32_t current_time = realtime_get_unixtime();
      if((release1_time != 0) &&
         (release2_time != 0) &&
         ((current_time-press1_time) > 3) &&
         ((current_time-press2_time) > 3) &&
         cap_ispressed(KEY_BACK  ) &&
         cap_ispressed(KEY_SELECT)) {
        system_gui->toggle_screen_lock();
        cap_clear_press();
      }

      power_wfi();
    }

    // should never get here
    for(int n=0;n<60;n++) {
      delay_us(100000);
      buzzer_blocking_buzz(1000);
    }
    return 0;
}