Пример #1
0
//
// Function: spotBarUpdate
//
// Update a single bar (used in Spotfire bar chart and cascade)
//
void spotBarUpdate(u08 x, u08 width, u08 oldVal, u08 newVal, s08 valXOffset,
  u08 fillType)
{
  u08 oldBarHeight;
  u08 newBarHeight;
  char barValue[3];

  // See if there's any need to update a bar
  if (oldVal == newVal && mcClockInit == GLCD_FALSE)
    return;

  // Get height of old bar and new bar
  oldBarHeight =
    (u08)((SPOT_BAR_HEIGHT_MAX / (float)SPOT_BAR_VAL_STEPS) * oldVal + 0.5);
  newBarHeight =
    (u08)((SPOT_BAR_HEIGHT_MAX / (float)SPOT_BAR_VAL_STEPS) * newVal + 0.5);

  // If there are no changes in barheight there's no need to repaint the bar
  if (oldBarHeight != newBarHeight || mcClockInit == GLCD_TRUE)
  {
    // Paint new bar
    if (fillType == FILL_BLANK)
    {
      // A FILL_BLANK is in fact drawing the outline of the bar first and
      // then fill it with blank
      glcdRectangle(x, SPOT_BAR_Y_START - newBarHeight, width,
        newBarHeight + 1, mcFgColor);
      if (newBarHeight > 1)
        glcdFillRectangle2(x + 1, SPOT_BAR_Y_START - newBarHeight + 1,
          width - 2, newBarHeight - 1, ALIGN_TOP, fillType, mcFgColor);
    }
    else
    {
      glcdFillRectangle2(x, SPOT_BAR_Y_START - newBarHeight, width,
        newBarHeight + 1, ALIGN_BOTTOM, fillType, mcFgColor);
    }
  }

  // Add the bar value (depending on bar value font size)
  animValToStr(newVal, barValue);
  glcdPutStr2(x + valXOffset, SPOT_BAR_Y_START - newBarHeight +
    SPOT_BAR_VAL_Y_OFFSET, FONT_5X7N, barValue, mcFgColor);

  // Clear the first line between the bar and the bar value
  glcdFillRectangle(x, SPOT_BAR_Y_START - newBarHeight - 1, width, 1,
    mcBgColor);

  // Clear the space left and right of the bar value
  glcdFillRectangle(x, SPOT_BAR_Y_START - newBarHeight + SPOT_BAR_VAL_Y_OFFSET,
    valXOffset, -SPOT_BAR_VAL_Y_OFFSET - 1, mcBgColor);
  glcdFillRectangle(x + width - valXOffset + 1,
    SPOT_BAR_Y_START - newBarHeight + SPOT_BAR_VAL_Y_OFFSET, valXOffset - 1,
    -SPOT_BAR_VAL_Y_OFFSET - 1, mcBgColor);

  // Clear what was above it (if any)
  if (oldBarHeight > newBarHeight)
    glcdFillRectangle(x, SPOT_BAR_Y_START - oldBarHeight +
      SPOT_BAR_VAL_Y_OFFSET, width, oldBarHeight - newBarHeight, mcBgColor);
}
Пример #2
0
//
// Function: analogAlarmAreaUpdate
//
// Draw update in analog clock alarm area
//
void analogAlarmAreaUpdate(void)
{
  u08 inverseAlarmArea = GLCD_FALSE;
  u08 newAlmDisplayState = GLCD_FALSE;

  if ((mcCycleCounter & 0x0F) >= 8)
    newAlmDisplayState = GLCD_TRUE;

  if (mcUpdAlarmSwitch == GLCD_TRUE)
  {
    if (mcAlarmSwitch == ALARM_SWITCH_ON)
    {
      // Show alarm time in small clock
      s08 dxM, dyM, dxH, dyH;
      float radM, radH;

      // Prepare the analog alarm clock
      radM = (2L * M_PI / ANA_SECMIN_STEPS) * mcAlarmM;
      dxM = (s08)(sin(radM) * ANA_ALARM_MIN_RADIUS);
      dyM = (s08)(-cos(radM) * ANA_ALARM_MIN_RADIUS);
      radH = (2L * M_PI / ANA_HOUR_STEPS) * (mcAlarmH % 12) +
        (2L * M_PI / ANA_SECMIN_STEPS / ANA_HOUR_STEPS) * mcAlarmM;
      dxH = (s08)(sin(radH) * ANA_ALARM_HOUR_RADIUS);
      dyH = (s08)(-cos(radH) * ANA_ALARM_HOUR_RADIUS);

      // Clear date area
      glcdFillRectangle(ANA_DATE_X_START, ANA_DATE_Y_START, ANA_DATE_X_SIZE,
        5, mcBgColor);

      // Show the alarm time
      glcdCircle2(ANA_ALARM_X_START, ANA_ALARM_Y_START, ANA_ALARM_RADIUS,
        CIRCLE_FULL, mcFgColor);
      glcdLine(ANA_ALARM_X_START, ANA_ALARM_Y_START, ANA_ALARM_X_START + dxM,
        ANA_ALARM_Y_START + dyM, mcFgColor);
      glcdLine(ANA_ALARM_X_START, ANA_ALARM_Y_START, ANA_ALARM_X_START + dxH,
        ANA_ALARM_Y_START + dyH, mcFgColor);
    }
    else
    {
      // Show date
      u08 pxDone = 0;
      char msg[4] = {0};

      // Clear alarm area
      glcdFillRectangle(ANA_ALARM_X_START - ANA_ALARM_RADIUS - 1,
        ANA_ALARM_Y_START - ANA_ALARM_RADIUS - 1, ANA_ALARM_RADIUS * 2 + 3,
        ANA_ALARM_RADIUS * 2 + 3, mcBgColor);
      mcU8Util1 = GLCD_FALSE;

      // Show the date
      char *s1, *s2;
#ifdef DATE_MONTHDAY
      s1 = (char *)months[mcClockNewDM - 1];
      s2 = msg;
      msg[0] = ' ';
      animValToStr(mcClockNewDD, &(msg[1]));
#else
      s1 = msg;
      s2 = (char *)months[mcClockNewDM - 1];
      animValToStr(mcClockNewDD, msg);
      msg[2] = ' ';
#endif
      pxDone = glcdPutStr2(ANA_DATE_X_START, ANA_DATE_Y_START, FONT_5X5P,
        s1, mcFgColor) + ANA_DATE_X_START;
      pxDone = pxDone + glcdPutStr2(pxDone, ANA_DATE_Y_START, FONT_5X5P, 
        s2, mcFgColor) - ANA_DATE_X_START;
      if (pxDone <= ANA_DATE_X_SIZE)
        glcdFillRectangle(ANA_DATE_X_START + pxDone, ANA_DATE_Y_START,
          ANA_DATE_X_SIZE - pxDone + 1, FILL_BLANK, mcBgColor);
    }
  }

  if (mcAlarming == GLCD_TRUE)
  {
    // Blink alarm area when we're alarming or snoozing
    if (newAlmDisplayState != mcU8Util1)
    {
      inverseAlarmArea = GLCD_TRUE;
      mcU8Util1 = newAlmDisplayState;
    }
  }
  else
  {
    // Reset inversed alarm area when alarming has stopped
    if (mcU8Util1 == GLCD_TRUE)
    {
      inverseAlarmArea = GLCD_TRUE;
      mcU8Util1 = GLCD_FALSE;
    }
  }

  // Inverse the alarm area if needed
  if (inverseAlarmArea == GLCD_TRUE)
    glcdFillRectangle2(ANA_ALARM_X_START - ANA_ALARM_RADIUS - 1,
      ANA_ALARM_Y_START - ANA_ALARM_RADIUS - 1, ANA_ALARM_RADIUS * 2 + 3,
      ANA_ALARM_RADIUS * 2 + 3, ALIGN_AUTO, FILL_INVERSE, mcBgColor);
}