コード例 #1
0
ESOS_CHILD_TASK(fast_read_child, uint8 u8_i2cAddress)
{
      static uint8_t u8_upperChar;
      static uint8_t u8_lowerChar;
      static uint8_t u8_bytesToRead;
      static uint8_t pau8_i2cData[8];
      //Increment write address by 1 so we have read address
      static uint8_t u8_i2cReadAddress;


      ESOS_TASK_BEGIN();
      //Read Address
      u8_i2cReadAddress = u8_i2cAddress + 1;
      //Get number of bytes to read
      ESOS_TASK_WAIT_ON_AVAILABLE_IN_COMM();
      ESOS_TASK_WAIT_ON_GET_UINT8(u8_upperChar);
      ESOS_TASK_SIGNAL_AVAILABLE_IN_COMM();
      ESOS_TASK_WAIT_ON_AVAILABLE_IN_COMM();
      ESOS_TASK_WAIT_ON_GET_UINT8(u8_lowerChar);
      ESOS_TASK_SIGNAL_AVAILABLE_IN_COMM();

      u8_bytesToRead = hexToUnsigned(u8_upperChar, u8_lowerChar);
      ESOS_TASK_WAIT_ON_READNI2C1(u8_i2cReadAddress, pau8_i2cData, u8_bytesToRead);
      ESOS_TASK_WAIT_ON_AVAILABLE_OUT_COMM();
      ESOS_TASK_WAIT_ON_SEND_U8BUFFER(pau8_i2cData, u8_bytesToRead);
      ESOS_TASK_SIGNAL_AVAILABLE_OUT_COMM();

      ESOS_TASK_END();
}
コード例 #2
0
ESOS_CHILD_TASK(fast_write_child, uint8 u8_i2cAddress)
{
    static uint8_t u8_upperChar;
    static uint8_t u8_lowerChar;
    static uint8_t u8_i2cData;

    ESOS_TASK_BEGIN();
    ESOS_TASK_WAIT_ON_AVAILABLE_IN_COMM();
    ESOS_TASK_WAIT_ON_GET_UINT8(u8_upperChar);
    ESOS_TASK_SIGNAL_AVAILABLE_IN_COMM();
    ESOS_TASK_WAIT_ON_AVAILABLE_IN_COMM();
    ESOS_TASK_WAIT_ON_GET_UINT8(u8_lowerChar);
    ESOS_TASK_SIGNAL_AVAILABLE_IN_COMM();

    u8_i2cData = hexToUnsigned(u8_upperChar, u8_lowerChar);
    ESOS_TASK_WAIT_ON_WRITE1I2C1(u8_i2cAddress, u8_i2cData);
    ESOS_TASK_END();
}
コード例 #3
0
// CHILD TASK THAT WILL HANDLE SETTING TEAM MEMBERS
ESOS_CHILD_TASK(members, bool stay, uint8_t team) {
  ESOS_TASK_BEGIN();
  esos_lcd_clearScreen(); // clear the screen
  static bool b_stay, b_update;
  static uint8_t numUsers, teamMembers;
  static int i_counter;
  numUsers = 0; // initial users is 0
  esos_lcd_setCursor(ROW_ONE, 1 );
  b_stay = stay; // this should be true
  if(team == 3) { // if teachers there are only 2
    i_counter = 8; // the counter needs to be set to the lowest index of team 3
    teamMembers = 10; // team members need to be set to highest + 1
  }
  else if(team == 2) {
    i_counter = 4; // counter needs to be set to lowest index of team 2
    teamMembers = 8; // team members need to be set to highest + 1
  }
  else {
    i_counter = 0; // counter set to lowest index of team 1
    teamMembers = 4; // team members set to highest + 1
  }
  while(i_counter <
        teamMembers) { // loop though and find any active users of the team
    if(ids[i_counter].active) {
      psz_netIDs[numUsers] = ids[i_counter].psz_netID; // add active users to the list
      numUsers++; // increase the number of users
    }
    i_counter++;
  }
  i_counter = 0;
  b_update = true; // set update to be true initially
  if(numUsers == 0) { // if no users send a message
    b_stay = FALSE;
    esos_lcd_setCursor(ROW_ONE, 1 );
    ESOS_TASK_WAIT_LCD_WRITE_DATA('N');
    ESOS_TASK_WAIT_LCD_WRITE_DATA('O');
    ESOS_TASK_WAIT_LCD_WRITE_DATA('N');
    ESOS_TASK_WAIT_LCD_WRITE_DATA('E');
    ESOS_TASK_WAIT_TICKS(2000);
  }
  while(b_stay) { // wait until a selection is made
    if(f15ui_isRpgTurningCCW() || f15ui_isSW2Pressed()) { // menu goes up
      i_counter++;
      b_update = TRUE; // update the screen
      if(i_counter > numUsers - 1) {
        i_counter = numUsers - 1;
        b_update = FALSE;
      }
    }
    else if(f15ui_isRpgTurningCW() || f15ui_isSW1Pressed()) { // menu goes down
      i_counter--;
      b_update = TRUE; // update the screen
      // if counter is going under item count, don't update
      if(i_counter < 0) {
        i_counter = 0;
        b_update = FALSE;
      }
    }
    if(b_update) {
      esos_lcd_setCursor(ROW_ONE, 1 );
      ESOS_TASK_WAIT_LCD_WRITE_DATA(psz_netIDs[i_counter][0]);
      ESOS_TASK_WAIT_LCD_WRITE_DATA(psz_netIDs[i_counter][1]);
      ESOS_TASK_WAIT_LCD_WRITE_DATA(psz_netIDs[i_counter][2]);
      ESOS_TASK_WAIT_LCD_WRITE_DATA(psz_netIDs[i_counter][3]);
      ESOS_TASK_WAIT_LCD_WRITE_DATA(psz_netIDs[i_counter][4]);
      ESOS_TASK_WAIT_LCD_WRITE_DATA(psz_netIDs[i_counter][5]);
      // if the menu is at the top display on the down arrow
      if(i_counter == 0) {
        esos_lcd_setCursor(ROW_ONE, 8 );
        ESOS_TASK_WAIT_LCD_WRITE_DATA(' ');
        esos_lcd_setCursor(ROW_TWO, 8 );
        ESOS_TASK_WAIT_LCD_WRITE_DATA(DOWN);
      }
      // if the menu is at the bottom display only the up arrow
      else if(i_counter == numUsers - 1) {
        esos_lcd_setCursor(ROW_ONE, 8 );
        ESOS_TASK_WAIT_LCD_WRITE_DATA(UP);
        esos_lcd_setCursor(ROW_TWO, 8 );
        ESOS_TASK_WAIT_LCD_WRITE_DATA(' ');
      }
      // otherwise display them both
      else {
        esos_lcd_setCursor(ROW_ONE, 8 );
        ESOS_TASK_WAIT_LCD_WRITE_DATA(UP);
        esos_lcd_setCursor(ROW_TWO, 8 );
        ESOS_TASK_WAIT_LCD_WRITE_DATA(DOWN);
      }
      b_update = FALSE;
    }
    ESOS_TASK_WAIT_TICKS(100);
    if(f15ui_isSW3Pressed()) {
      b_stay = FALSE;
      int i = 0;
      while(i < 10) {
        if(psz_netIDs[i_counter] == ids[i].psz_netID) {
          u8_currentMenuIndex = i;
          char id;
          if(i == MY_ID) {
            id = ID_to_Char(0);
          }
          else {
            id = ID_to_Char(ids[i].u8_index);
          }
          esos_insert_menu_title(WAVEFORM, SET, SV3C, "wvform", id);
          esos_insert_menu_title(FREQ, SET, SVDATA, "freq", id);
          esos_insert_menu_title(AMPLTD, SET, SVDATA, "ampltd", id);
          esos_insert_menu_title(DUTY, SET, SVDATA, "duty", id);
          esos_insert_menu_title(LM60, READ, NONE, "LM60", id);
          esos_insert_menu_title(LEDSET, SET, SVDATA, "LEDs", id);
          esos_setSV3C_VALUE(WAVEFORM, ids[i].u8_wave);
          esos_setSVDATAValue(FREQ, ids[i].u16_freq); // set the default duty cycle
          esos_setSVDATAValue(AMPLTD, ids[i].u16_amp); // set the default ampl
          esos_setSVDATAValue(DUTY, ids[i].u16_duty); // set the default duty cycle
          esos_setSVDATAValue(LEDSET, ids[i].u8_leds); // set the default duty cycle
        }
        i++;
      }
      i_counter = 0;
    }
  }
  ESOS_TASK_END();
}