Exemplo n.º 1
0
void thread(void)
{
	unsigned int id;
	
	id = OS_Id();
	PF3 ^= 0x08;
	Display_Message(0,line++, "Thread: ", id);
	OS_Sleep(2000);
	Display_Message(0,line++, "Thread dying ", id);
	PF3 ^= 0x08;
	OS_Kill();
}
Exemplo n.º 2
0
int main(void)
{
	unsigned int id;
	unsigned long time;	
	id = OS_Id();
	PF2 ^= 0x04;
	Display_Message(0,line++, "Hello world: ", id);
	OS_AddThread(thread, 128, 1);
  time = OS_Time();
	OS_Sleep(1000);
	time = (((OS_TimeDifference(time, OS_Time()))/1000ul)*125ul)/10000ul;
	Display_Message(0,line++, "Sleep time: ", time);
	PF2 ^= 0x04;
	OS_Kill();
}
Exemplo n.º 3
0
void routine_text_out(int y, int x, char *sBuf, int nOffset)
{
    int i = 0, k = 0, len;
    char sLine[512];

    for (i = 0; i < nOffset; ++i)
        if (ch_ischinese(sBuf + i))
           ++i;
    sBuf += i;
    
    memset(sLine, 0, sizeof(sLine));
    for (i = 0; i < strlen(sBuf); ++i) {
        if (ch_ischinese(sBuf + i)) {
            sLine[k++] = sBuf[i++];
            sLine[k++] = sBuf[i];
            if (k == DISPLAY_WIDTH - 1) break;
            if (k > DISPLAY_WIDTH - 1) {
                sLine[k - 2] = ' ';
                sLine[k - 1] = '\0';
                break;
            }
        } else {
            sLine[k++] = sBuf[i];
            if (k >= DISPLAY_WIDTH - 1) break;
        }
    }
    for (i = k; i < DISPLAY_WIDTH - 1; ++i)
        sLine[i] = ' ';
    sLine[i] = 0;
    Display_Message(y, x, sLine);
}
Exemplo n.º 4
0
int
main(void)
 {
     char * str ="Hello Cursor\n";
     Display_Message(10,10,str);
     //Display_Cursor();
     //Hide_Cursor();
     //Clear_All_Display();
     //Clear_Screen();
     //Display_Message(24,20,str);
     //Move_Cursor(40,20);
     Draw_Box(20,40,10,20);
     return EXIT_SUCCESS;
 }
void main() {
  Display_Init();
  MCU_Init();
  #ifdef INIT_BLE
  BLE_Init();
  delay_ms(2000);
  #else
  RN_WAKE = 1;
  wait_response("CMD");
  #endif
  DrawFrame();
  InitTimer2();
  while(1)
  {
    if(data_ready)
    {
      //If characteristic is configured as write
      //received messages come here
      Display_Message();
      reset_buff();
    }
    else
    {
       //Test: every 5sec increase baterry level (0 to 100%)
       //and send value via Bluetooth Low Energy
       if (tmr_flg)
       {
          batt_level++;
          if(batt_level > 100)
          {
            batt_level = 0;
          }
          Display_BatteryLevel();
          if(RN_CONN)
          { //send battery level value if BLE connected
            shorttohex(batt_level, batt_level_txt);
            ltrim(batt_level_txt);
            ble2_write_server_characteristic_value_via_UUID("2A19",batt_level_txt);
          }
          tmr_flg = 0;
       }
    }
  }
}