Exemple #1
0
/*
 * @brief Interrupt Request Handler for TIM14
 * @params None
 * @retval None
 */
void TIM14_IRQHandler(void) {
  // Check the battery voltage
  check_battery();

  // Clear the interrupt pending bit
  TIM14->SR &= ~TIM_SR_UIF;
}
Exemple #2
0
/**
 * Check for various problems and complain until they are fixed.
 */
task check() {
    while (true) {
        if (check_battery() == false) {
            playSound(soundException);
        }

        wait1Msec(5 * 1000);
    }
}
static gboolean
check_all_batteries (gpointer data)
{
	HAL_DEBUG (("** Check batteries"));
	/* TODO: make it configurable (not to rescan every time) */
	usb_find_busses ();
	usb_find_devices ();
	check_battery (device_udi, dev_props);
	return TRUE;
}
Exemple #4
0
static PyObject *pcf8523_check_battery(PyObject *self, PyObject *args)
{
    char ok;
    
    ok = check_battery(); 
    if (ok < 0)
    {
        PyErr_SetString(PyExc_RuntimeError, "ERROR: battery check failed, result unknown.");
    }
    
    PyObject *ret = Py_BuildValue("b", ok);
    return ret;
}
Exemple #5
0
uint8_t status_process(uint8_t event, uint16_t lparam, void* rparam)
{
  uint8_t old_status = status;
  switch(event)
  {
  case EVENT_WINDOW_CREATED:
    status = 0;
    check_battery();
    status_invalid();
    break;
  case EVENT_WINDOW_PAINT:
    OnDraw((tContext*)rparam);
    break;
  case PROCESS_EVENT_TIMER:
    {
      uint8_t hour, minute, second;
      rtc_readtime(&hour, &minute, &second);

      if (hour == 0 && minute == 0 && second <= 30)
      {
        on_midnigth(event, lparam, rparam);
      }

      if (s_cur_min != minute &&
        (get_mode() == DATA_MODE_NORMAL || (get_mode() & DATA_MODE_PAUSED) != 0))
      {
        s_cur_min = minute;
        record_activity_data(hour, minute);
      }

#if 0
      //sports watch pause/resume
      uint16_t ws_status = get_watch_status();
      if (ws_status != WS_NORMAL)
      {
        if (check_idle_time() > 60)
        {
          if (ws_status & WS_NOTIFY)
          {
            //TODO: close current front-end window
          }
          else if (ws_status & WS_SPORTS)
          {
            //TODO: open sports watch
          }
        }
      }
#endif

      //if (minute % 5 == 0)
      check_battery();

      //check alarms
      ui_config* uiconf = window_readconfig();
      for (int i = 0; i < sizeof(uiconf->alarms) / sizeof(uiconf->alarms[0]); ++i)
      {
        if (uiconf->alarms[i].flag != 0 &&
            uiconf->alarms[i].hour    == hour &&
            uiconf->alarms[i].minutes == minute &&
            second <= 30)
        {
          uint8_t ispm;
          adjustAMPM(hour, &hour, &ispm);
          sprintf(alarmtext, "%02d:%02d %s", hour, minute, ispm?"PM":"AM");
          window_messagebox(ICON_LARGE_ALARM, alarmtext, NOTIFY_ALARM);
          break;
        }
      }

      status ^= MID_STATUS;
      break;
    }
  case EVENT_BT_STATUS:
    if (lparam == BT_CONNECTED)
      status |= BLUETOOTH_STATUS;
    else if (lparam == BT_DISCONNECTED)
      status &= ~BLUETOOTH_STATUS;
    break;
  case EVENT_ANT_STATUS:
    break;
  default:
    return 0;
  }

  if (status != old_status)
    status_invalid();
  return 1;
}
Exemple #6
0
void update_status()
{
    #ifdef DEBUG
    char buffer[256];
    sprintf(buffer, "Update Status: draw Memory %s", sbar_status_symbols[DrawMemory].active ? "yes" : "no");
    log_str(buffer, LOG_DEBUG);
    sprintf(buffer, "Update Status: draw Battery %s", sbar_status_symbols[DrawBattery].active ? "yes" : "no");
    log_str(buffer, LOG_DEBUG);
    sprintf(buffer, "Update Status: draw Uptime %s", sbar_status_symbols[DrawUptime].active ? "yes" : "no");
    log_str(buffer, LOG_DEBUG);
    sprintf(buffer, "Update Status: draw Termal %s", sbar_status_symbols[DrawTermal].active ? "yes" : "no");
    log_str(buffer, LOG_DEBUG);
    #ifdef NF310_A01
    sprintf(buffer, "Update Status: draw Backlight %s", sbar_status_symbols[DrawBacklight].active ? "yes" : "no");
    log_str(buffer, LOG_DEBUG);
    #endif
    sprintf(buffer, "Update Status: draw Net %s", sbar_status_symbols[DrawNet].active ? "yes" : "no");
    log_str(buffer, LOG_DEBUG);
    #endif
    
    if(sbar_status_symbols[DrawMemory].active) {
      get_memory();
      
      #ifdef DEBUG
      log_str("Sucessfully Updated Memory", LOG_DEBUG);
      #endif
    }
    
    if(sbar_status_symbols[DrawBattery].active) {
      check_battery();

      #ifdef DEBUG
      log_str("Sucessfully Updated Battery", LOG_DEBUG);
      #endif
    }

    cpu_usage();

    #ifdef DEBUG
    log_str("Sucessfully Updated CPU", LOG_DEBUG);
    #endif

    update_date();

    #ifdef DEBUG
    log_str("Sucessfully Updated Date", LOG_DEBUG);
    #endif

    if(sbar_status_symbols[DrawUptime].active) {
      update_uptime();

      #ifdef DEBUG
      log_str("Sucessfully Updated Uptime", LOG_DEBUG);
      #endif
    }

    if(sbar_status_symbols[DrawTermal].active) {
      get_thermal();

      #ifdef DEBUG
      log_str("Sucessfully Updated Termal", LOG_DEBUG);
      #endif
    }

    #ifdef NF310_A01
    if(sbar_status_symbols[DrawBacklight].active) {
      update_backlight();

      #ifdef DEBUG
      log_str("Sucessfully Updated Backlight", LOG_DEBUG);
      #endif
    }
    #endif

    if(sbar_status_symbols[DrawNet].active) {
      update_net();

      #ifdef DEBUG
      log_str("Sucessfully Updated Net", LOG_DEBUG);
      #endif
    }

    update_disk();

    #ifdef DEBUG
    log_str("Sucessfully Updated Disk", LOG_DEBUG);
    #endif

}