Пример #1
0
void DisplayGraph(void)
{
  if (Event == EV_FUNC_FIRST)
  {
    LcdBlank(); /* Clear screen */
    GlobalDiapason = 0xFF;
    PrintGraph();
    return;
  }
  if ( (Event& EV_MASK) == EV_KEY_PRESSED )
  {
    switch (Event & KEY_MASK)
    {
      case KEY_ENTER:
        CurrentFunc(StartFunction);
        return;
      case KEY_DOWN:
      case KEY_UP:
        CurrentFunc(SetupGraph);
        return;
      case KEY_ADC:
      {
        int16_t ValueMin;
        int16_t ValueMax;
        uint8_t Next;


        ValueMin = GraphData.GraphArray[GraphCurrentPoint].Min;
        ValueMax = GraphData.GraphArray[GraphCurrentPoint].Max;
        if (ValueMin < GlobalMin || ValueMax > GlobalMax || /* Larger diapason */
            GraphCurrentPoint == GlobalMaxPoint || GraphCurrentPoint == GlobalMinPoint) /* Check Diapason */
        {
          PrintGraph();
          return;
        }

        Next = GraphCurrentPoint + 1;
        if ( Next >= GRAPH_SIZE)
          Next = 0;

        OutOneColumn(GraphData.GraphArray, GraphCurrentPoint);
        OutOneColumn(GraphData.GraphArray, Next);

        return;
      }
    }
  }
  return;
}
Пример #2
0
static void SetupGraph(void)
{
  if (Event == EV_FUNC_FIRST)
  {
    LcdBlank(); /* Clear screen */
    MenuPos = 0;
    IntervalCorrection = 0;
    EncCounter = TimeInterval - 1;
    goto redraw;
  }
  if ( (Event& EV_MASK) == EV_KEY_PRESSED )
  {
    switch (Event & KEY_MASK)
    {
      case KEY_UP:
        if (IntervalCorrection == 0)
        {
          MenuPos++;
          if ( MenuPos > 2 )
            MenuPos = 0;
          goto redraw;
        }
      case KEY_DOWN:
        if (IntervalCorrection == 0)
        {
          if ( MenuPos == 0 )
            MenuPos = 2;
          else
            MenuPos--;
          goto redraw;
        }
        TimeInterval = EncCounter + 1;
        goto redraw;

      case KEY_ENTER:
        switch (MenuPos)
        {
          case 1: /* Clear */
            ClearGraph();
          case 0: /* Return */
            CurrentFunc(DisplayGraph);
            return;
          default: /* Interval */
            if ( IntervalCorrection == 0)
              IntervalCorrection = 1;
            else
            {
              IntervalCorrection = 0;
            }
        }
    }
  }      
  return;

redraw:  
  LcdChr(14+1*Y_POSITION+0*X_POSITION + (MenuPos==0?INVERSE:0), "Return");
  LcdChr(14+2*Y_POSITION+0*X_POSITION + (MenuPos==1?INVERSE:0), "Clear");
  LcdChr(14+3*Y_POSITION+0*X_POSITION + (MenuPos==2?INVERSE:0), "Interval");
  OutValueSmall(3, 9, TimeInterval*2, 3, MenuPos==2?1:0);
}
Пример #3
0
void SelectDot(void)
{
  if (Event == EV_FUNC_FIRST)
  {
    LcdBlank(); /* Clear screen */
    goto redraw;
  }

  if ( (Event & EV_MASK) == EV_KEY_PRESSED )
  {
    switch (Event & KEY_MASK)
    {
      case KEY_UP:
        Cur->DotPosition++;
        if (Cur->DotPosition>4)
          Cur->DotPosition = 4;
        goto redraw;
      case KEY_DOWN:
        Cur->DotPosition--;
        if (Cur->DotPosition<0)
          Cur->DotPosition = 0;
        goto redraw;
      case KEY_ENTER:
        CurrentFunc(SetDac);
    }
  }

  return;
redraw:
  LcdChr(X_POSITION*0+Y_POSITION*1+14, Text);
  LcdChr(X_POSITION*0+Y_POSITION*2+14, "Set Dot");
  OutValue(3, 1, Cur->Out, Cur->DotPosition, 0xFF);
}
Пример #4
0
void SetDac(void)
{
  if (Event == EV_FUNC_FIRST)
  {
    LcdBlank(); /* Clear screen */
    LcdChr(X_POSITION*0+Y_POSITION*1+14, Text);
    LcdChr(X_POSITION*0+Y_POSITION*2+14, "Set Out");
    EncCounter = Cur->Dac;
    goto redraw;
  }
  if ( (Event & EV_MASK) == EV_KEY_PRESSED )
  {
    switch (Event & KEY_MASK)
    {
      case KEY_UP:
      case KEY_DOWN:
        Cur->Dac = EncCounter;
        goto redraw;
   case KEY_ENTER:
        CurrentFunc(WaitMeasure);
    }
  }

  return;
redraw:
  OutValue(3, 1, Cur->Dac, 4,  0xFF);
  *CurDac = Cur->Dac;
  OutValueSmall(5,0, EncStep, 4, 0);
}
Пример #5
0
void CalibrationMenu(void)
{
  /* Init The calibration */
  VMax.Ok = 0;
  VMin.Ok = 0;
  IMax.Ok = 0;
  IMin.Ok = 0;
  CurrentFunc(CalibrationMenuInternal);
}
Пример #6
0
void MainMenu()
{
  if ( Event == 0 )
    return;

  if ( Event == EV_FUNC_FIRST )
  {
    MenuCounter = 0;
    LcdClear();
    goto RedrawMenu;
  }

  if ( (Event & EV_MASK) == EV_KEY_PRESSED )
  {
    switch (Event & KEY_MASK)
    {
      case KEY_UP:
        if ( MenuCounter == 0 )
          MenuCounter = 6;
        else
          MenuCounter = MenuCounter - 1;
        break;
      case KEY_DOWN:
        if ( MenuCounter == 6 )
          MenuCounter = 0;
        else
          MenuCounter = MenuCounter + 1;
        break;
      case KEY_ENTER:
        switch(MenuCounter)
        {
          case 4: // Установка контрастности
            CurrentFunc(Contrast);
            break;
          case 5:
//            GPIO_TOGGLE(LCD_LED);
            break;
          case 6:
//            GPIO_RESET(PWR_ON);
            break;
          default:
            CurrentFunc(MenuSelected;)
            return;
        }
    }
  }
Пример #7
0
void ContrastMenu(void)
{
  if (Event == EV_FUNC_FIRST)
  {
//    Contrast = CurrentSettings.VoltageDAC>>12;
    LcdBlank(); /* Clear screen */
    LcdChr(Y_POSITION*1 + X_POSITION * 0 + 14, "Contrast");
    LcdChr(Y_POSITION*4 + X_POSITION * 0 + 14, "Press");
    LcdChr(Y_POSITION*5 + X_POSITION * 0 + 14, "to exit");
    goto redraw;
  }
  if ( (Event & EV_MASK) == EV_KEY_PRESSED )
  {
    switch (Event & KEY_MASK)
    {
      case KEY_UP:
        if ( Contrast < 15 )
          Contrast++;
        break;
      case KEY_DOWN:
        if ( Contrast > 0 )
          Contrast--;
        break;
      case KEY_ENTER:
        LcdContrast ( Contrast*3+42 );
        CurrentFunc(AfterContrast);
         return;
    }
redraw:
    LcdContrast ( Contrast*3+42 );
    {
      char Buf[2];
      uint8_t Counter = Contrast;
      
      Buf[0] = Counter/10 + '0';
      Counter = Counter%10;
      Buf[1] = Counter + '0';
      LcdChr(BIG_UP+Y_POSITION*2 + X_POSITION * 2 + 2, Buf);
      LcdChr(BIG_DOWN+Y_POSITION*3 + X_POSITION * 2 + 2, Buf);
    }
  }
}
Пример #8
0
void SaveMenu(void)
{
  if (Event == EV_FUNC_FIRST)
  {
    MenuMode = 0;
    LcdBlank(); /* Clear screen */
    goto redraw;
  }

  if ( (Event & EV_MASK) == EV_KEY_PRESSED )
  {
    switch (Event & KEY_MASK)
    {
      case KEY_UP:
        if ( MenuMode == 0 )
          MenuMode = 1;
        break;
      case KEY_DOWN:
        if ( MenuMode != 0 )
          MenuMode = 0;
        break;
      case KEY_ENTER:
        if (MenuMode != 0)
        {
          SaveConfig();
        }
        CurrentFunc(StartFunction);
        return;
    }
  }
  else
    return;

redraw:
  LcdChr(X_POSITION*0+Y_POSITION*1+14 + (0==MenuMode)*INVERSE, "Save to memory");
  LcdChr(X_POSITION*0+Y_POSITION*2+14 + (1==MenuMode)*INVERSE, "Save to flash");
}
Пример #9
0
void WaitMeasure(void)
{
  if (Event == EV_FUNC_FIRST)
  {
    LcdBlank(); /* Clear screen */
    LcdChr(X_POSITION*0+Y_POSITION*3+14, "Please wait");
    MenuMode = 0;
    return;
  }

  if ( (Event & EV_MASK) == EV_KEY_PRESSED &&
       (Event & KEY_MASK) == KEY_ADC ) /* End of conversion */
  {
    if (MenuMode == 2)
    {
      CurrentFunc(SetOut);
      if ( Cur == &VMax || Cur == &VMin )
        Cur->Adc = ADCVoltage;
      else
        Cur->Adc = ADCCurrent;
    }
    MenuMode++;
  }
}
Пример #10
0
void CalibrationMenuInternal(void)
{
  if (Event == EV_FUNC_FIRST)
  {
    MenuMode = 0;
    LcdBlank(); /* Clear screen */
    goto redraw;
  }

  if ( (Event & EV_MASK) == EV_KEY_PRESSED )
  {
    switch (Event & KEY_MASK)
    {
      case KEY_DOWN:
        if ( MenuMode == 0 )
          MenuMode = 4;
        else
          MenuMode = MenuMode - 1;
        goto redraw;
      case KEY_UP:
        if ( MenuMode == 4 )
          MenuMode = 0;
        else
          MenuMode = MenuMode + 1;
        goto redraw;
      case KEY_ENTER:
        switch(MenuMode)
        {
          case 0:
            Cur = &VMax;
            Text = "Max Voltage";
            Cur->Dac = 3700;
            Cur->Out = 5555;
            Cur->DotPosition = 2;
            CurDac = &DAC_V;
            CurrentFunc(SelectDot);
            return;
          case 1:
            if (VMax.Ok == 0 ) /* The max value has not been set */
              return;
            Cur = &VMin;
            Text = "Min Voltage";
            Cur->Dac = 350;
            Cur->Out = 555;
            Cur->DotPosition = VMax.DotPosition;
            CurDac = &DAC_V;
            CurrentFunc(SetDac);
            return;
          case 2:
            Cur = &IMax;
            Text = "Max Current";
            Cur->Dac = 3700;
            Cur->Out = 5555;
            Cur->DotPosition = 2;
            CurDac = &DAC_I;
            DAC_V = 2000; /* Set intermidiate voltage value !!! */
            CurrentFunc(SelectDot);
            return;
          case 3:
            if (IMax.Ok == 0 ) /* The max value has not been set */
              return;
            Cur = &IMin;
            Text = "Min Current";
            Cur->Dac = 350;
            Cur->Out = 555;
            Cur->DotPosition = IMax.DotPosition;
            CurDac = &DAC_I;
            CurrentFunc(SetDac);
            return;
          default:
            if ( VMax.Ok && VMin.Ok && IMax.Ok && IMin.Ok )
            {
              CalibrationToConfig(&CurrentConfig);
              CurrentFunc(SaveMenu);
            }
            return;
        }
    }
  }
  return;
  
redraw:
  LcdChr(X_POSITION*0+Y_POSITION*1+14 + (0==MenuMode)*INVERSE, "Max Voltage");
  LcdChr(X_POSITION*0+Y_POSITION*2+14 + (1==MenuMode)*INVERSE, "Min Voltage");
  LcdChr(X_POSITION*0+Y_POSITION*3+14 + (2==MenuMode)*INVERSE, "Max Current");
  LcdChr(X_POSITION*0+Y_POSITION*4+14 + (3==MenuMode)*INVERSE, "Min Current");
  if ( VMax.Ok && VMin.Ok && IMax.Ok && IMin.Ok )
  {
    LcdChr(X_POSITION*0+Y_POSITION*5+14 + (4==MenuMode)*INVERSE, "Ok");
  }
  else
  {
    LcdChr(X_POSITION*0+Y_POSITION*5+14 + (4==MenuMode)*INVERSE, "");
  }
}
Пример #11
0
void SetOut(void)
{
  if (Event == EV_FUNC_FIRST)
  {
    LcdBlank(); /* Clear screen */
    MenuMode = 0;
    IncrementMul = 1000;
    ChangeNumberFlag = 0;
    LcdChr(X_POSITION*0+Y_POSITION*1+14, Text);
    LcdChr(X_POSITION*0+Y_POSITION*2+14, "Set Out");
    LcdChr(X_POSITION*0+Y_POSITION*5+14, "Longkey to end");
    goto redraw;
  }
  if ( (Event & EV_MASK) == EV_KEY_PRESSED )
  {
    switch (Event & KEY_MASK)
    {
      case KEY_UP:
        if ( ChangeNumberFlag )
        {
          Cur->Out += IncrementMul;
          goto redraw;
        }
        else
        {
          if ( MenuMode < 3 )
          {
            IncrementMul /= 10;
            MenuMode++;
            goto redraw;
          }
        }
        return;
      case KEY_DOWN:
        if ( ChangeNumberFlag )
        {
          Cur->Out -= IncrementMul;
          goto redraw;
        }
        else
        {
          if ( MenuMode > 0 )
          {
            IncrementMul *= 10;
            MenuMode--;
            goto redraw;
          }
        }
        return;
      case KEY_ENTER:
        if ( ChangeNumberFlag == 0 )
          ChangeNumberFlag = 1;
        else
          ChangeNumberFlag = 0;
        return;
    }
  }
  if ( (Event & EV_MASK) == EV_KEY_LONG )
  {
    Cur->Ok = 1;
    CurrentFunc(CalibrationMenuInternal);
  }

  return;

redraw:
  OutValue(3, 1, Cur->Out, Cur->DotPosition, MenuMode);
}