예제 #1
0
/*..........................................................................*/
static QState ModIo2Mgr_initial(ModIo2Mgr *me, QEvent const *e) {
    (void)e;        /* suppress the compiler warning about unused parameter */

    QActive_subscribe((QActive *)me, ENABLE_RELAY_SIG);
    QActive_subscribe((QActive *)me, DISABLE_RELAY_SIG);
    QActive_subscribe((QActive *)me, TERMINATE_SIG);

    QS_OBJ_DICTIONARY(&l_modIo2Mgr);
    QS_FUN_DICTIONARY(&QHsm_top);
    QS_FUN_DICTIONARY(&ModIo2Mgr_initial);
    QS_FUN_DICTIONARY(&ModIo2Mgr_running);

    QS_SIG_DICTIONARY(ENABLE_RELAY_SIG,  0);
    QS_SIG_DICTIONARY(DISABLE_RELAY_SIG, 0);
    QS_SIG_DICTIONARY(TERMINATE_SIG,     0);

    if (ModIO2_init() == Error)
    {
      LCDPutStr("Err MODIO2 init", 110, 5, LARGE, RED, WHITE);
      return Q_UNHANDLED();
    }
    else
    {
      return Q_TRAN(&ModIo2Mgr_running);
    }
}
예제 #2
0
int main( int argc, char *argv[])
{
	// Imposto i valori iniziali della dimensione dell'LCD...
	rect.x=LCD_X_OFFSET;
	rect.y=LCD_Y_OFFSET;
	rect.w=LCD_WIDTH-1;
	rect.h=LCD_HEIGHT-1;
	rect.r=rect.g=rect.b=0;

	font.x=LCD_X_OFFSET;
	font.y=LCD_Y_OFFSET;
	font.size=SMALL;
	font.fr=font.fg=font.fb=250;	// foreground == WHITE
	font.br=font.bg=font.bb=0;	// background == BLACK

	parse_opts(argc, argv);
	
	// Inizializzo l'LCD della Nokia, controller compatibile al PCF8833
	InitLcd( PCF8833, device);
	
	if ( noreset==0) LCDReset();
	
	if ( clearcmd) {
		LCDDrawScreen( RGB( rect.r, rect.g, rect.b));
		usleep( 250000);
	}

	if ( isStringToDsiplay) {
		if ( strlen( StringToDsiplay)==1 && StringToDsiplay[0]=='-') {	// stdin
			StringToDsiplay=readLine( stdin );
		}

		LCDSetCurr_XY( rect.x, rect.y);
		LCDPutStr( StringToDsiplay, font.x, font.y, font.size, RGB(font.fr,font.fg, font.fb), RGB(font.br,font.bg, font.bb));
	}

	if ( (filename != (const char*)NULL) && isImage) LCDWritebmp( (const char*)filename, rect.x, rect.y, rect.w, rect.h);
	//if ( (FullScreenFilename != (const char*)NULL) && isFullScreen) LCDWriteRGB( (const char*)FullScreenFilename);
	if ( (FullScreenFilename != (const char*)NULL) && isFullScreen) LCDWriteFullScreenRGB_2( (const char*)FullScreenFilename);
	if ( (MoveFilename != (const char*)NULL) && isMovie) {
		if ( LoopFor == -1) {
			if (LCDMovieRGB( (const char*)MoveFilename)) {
				return 1;
			}
		} else {
			while( LoopFor--) {
				if (LCDMovieRGB( (const char*)MoveFilename)) {
					return 1;
				}
			}
		}
	}


	return 0;
}
예제 #3
0
void infoTemplate(char *information)
{
    int centerX = ROW_LENGTH/2;
    int centerY = COL_HEIGHT/2;

    //Clear previous information
    LCDSetRect(0, centerY - 9, ROW_LENGTH-1, 2*9, FILL, WHITE);
    //Information
    LCDPutStr(information, centerX - strlen(information)/2*8, centerY - 8, LARGE, WHITE, RED);
    delay(200);
}
예제 #4
0
void basicTemplate(char *screenTitle, char *information, char *prevScreen, char *nextScreen)
{
    LCDClear(WHITE);
    // Header
    //// Screen Title
    ////// Top Bar
    LCDSetRect(0, 0, COL_HEIGHT-1, 25, FILL, RED);

    ////// Screen Title - Centered over the Top Bar
    int centerX = COL_HEIGHT/2;
    int centerY = 25/4;
    LCDPutStr(screenTitle, centerX - strlen(screenTitle)/2*8+2, centerY, LARGE, WHITE, RED);

    //Information
    centerX = ROW_LENGTH/2;
    centerY = COL_HEIGHT/2;
    LCDPutStr(information, centerX - strlen(information)/2*8, centerY - 8, LARGE, WHITE, RED);


    // Footer
    //// Navigation Bar
    ////// Bottom Bar
    LCDSetRect(0, COL_HEIGHT-20-1, ROW_LENGTH-1, 20, FILL, RED);

    //////// Previous Screen String
    centerX = ROW_LENGTH/4;
    centerY = COL_HEIGHT - (20 - 20/4);
    LCDPutStr(prevScreen, centerX - strlen(prevScreen)/2*8+2, centerY, MEDIUM, WHITE, RED);

    //////// Divider
    LCDSetRect(ROW_LENGTH/2 - 5, COL_HEIGHT-20-1, 10, 20, FILL, BLACK);

    //////// Next Screen String
    centerX = ROW_LENGTH/4 + ROW_LENGTH/2;
    centerY = COL_HEIGHT - (20 - 20/4);
    LCDPutStr(nextScreen, centerX - strlen(nextScreen)/2*8+2, centerY, MEDIUM, WHITE, RED);

    //delay(500);
}
예제 #5
0
void draw_info_screen( unsigned int keys )
{
  int i = 0;
  unsigned int xoffset = LCD_WIDTH;

  if( keys & (BTN_GREEN | BTN_RED) ) {
    current_app_state = DO_HALF_MENU;
    do_redraw = true;
    return;
  }

  if( do_redraw ) {
    LCDFillScreen( MENU_BG );
    for( i = 0; (i < FULL_MENU_NUM_ITEMS)&&(info_strings[i]!=NULL); i++ ) {
      xoffset = (LCD_WIDTH - 8 * strlen(info_strings[i])) >> 1;

      LCDPutStr( info_strings[i], i*LINE_HEIGHT, xoffset, MENU_FONT, MENU_FG, MENU_BG );
    }
  }

  do_redraw = false;
}
예제 #6
0
void erase_consumo(){
	//lcd_fill_rectangle(P_Y+DIGIT_SIZE*( sizeof(temperatura)-1 ) , P_X, 132, 132, WHITE);
	LCDPutStr( "      ", P_X, P_Y+DIGIT_SIZE*( sizeof(consumo)-1 ), BLACK, WHITE);
}
예제 #7
0
void erase_current(){
	//lcd_fill_rectangle(P_Y+DIGIT_SIZE*( sizeof(temperatura)-1 ) , P_X, 132, 132, WHITE);
	LCDPutStr( "      ", I_X, I_Y+DIGIT_SIZE*( sizeof(corrente)-1 ), BLACK, WHITE);
}
예제 #8
0
// ______________________________-  Apagar
void erase_voltage(){
	//lcd_fill_rectangle(U_Y+DIGIT_SIZE*( sizeof(tensao)-1 ) , U_X, 132, 132, WHITE);
	LCDPutStr( "      ", U_X, U_Y+DIGIT_SIZE*( sizeof(tensao)-1 ), BLACK, WHITE);
}
예제 #9
0
void displayMenu_humidade(){
	LCDPutStr( (char *)humidade, HUM_X, HUM_Y, BLACK, WHITE);	
}
예제 #10
0
void displayMenu_temperatura(){
	LCDPutStr( (char *)temperatura, T_X, T_Y, BLACK, WHITE);
	LCDPutChar( grau, T_X, GRAU_POS_STRING * DIGIT_SIZE, BLACK, WHITE);	
}
예제 #11
0
void displayMenu_consumo(){
	LCDPutStr( (char *)consumo, P_X, P_Y, BLACK, WHITE);
}
예제 #12
0
// ************************** Etiqueta
void displayMenu_voltage(){
	LCDPutStr( (char *)tensao, U_X, U_Y, BLACK, WHITE);
}
예제 #13
0
void display_title(){
	//Escrever Titulo
	LCDPutStr( (char *)id, 5, 20, BLACK, WHITE);
	lcd_fill_rectangle(20, DIGIT_SIZE+5, DIGIT_SIZE*(sizeof(id)-1), 2, BLACK);//____
}
예제 #14
0
int32_t main(void) {

  int32_t i,cnt=0;
  uint8_t RC5_System_prev=0;
  uint8_t RC5_Command_prev=0;
  CHIP_PMU_MCUPOWER_T mcupower=PMU_MCU_SLEEP;

  SystemCoreClockUpdate();

// init GPIO
  Chip_GPIO_Init(LPC_GPIO_PORT);
  Chip_SYSCTL_PeriphReset(RESET_GPIO);

// init SPI0 at SystemCoreClock speed
  Chip_SPI_Init(LPC_SPI0);
  Chip_SPI_ConfigureSPI(LPC_SPI0,SPI_MODE_MASTER|
                                 SPI_CLOCK_CPHA0_CPOL0|
                                 SPI_DATA_MSB_FIRST|
                                 SPI_SSEL_ACTIVE_LO);
  LPC_SPI0->DIV=0;
  Chip_SPI_Enable(LPC_SPI0);

// init MRT
  Chip_MRT_Init();

// init SWM
  Chip_SWM_Init();
  Chip_SWM_DisableFixedPin(SWM_FIXED_SWCLK);//PIO0_3
  Chip_SWM_DisableFixedPin(SWM_FIXED_SWDIO);//PIO0_2
  Chip_SWM_DisableFixedPin(SWM_FIXED_ACMP_I2);//PIO0_1
  Chip_SWM_DisableFixedPin(SWM_FIXED_ACMP_I1);//PIO0_0
  Chip_SWM_MovablePinAssign(SWM_SPI0_SCK_IO,CLK_PIN);
  Chip_SWM_MovablePinAssign(SWM_SPI0_MOSI_IO,MOSI_PIN);
  Chip_SWM_MovablePinAssign(SWM_CTIN_0_I,IR_PIN);
  Chip_SWM_Deinit();

// init onboard LED
  Chip_GPIO_SetPinState(LPC_GPIO_PORT,0,LED_PIN,true);
  Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT,0,LED_PIN);

// init LCD reset pin
  Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT,0,RESET_PIN);

// init LCD
  LCDInit();
  LCDClearScreenBlack();

// init SCT
  Chip_SCT_Init(LPC_SCT);
  // set prescaler, SCT clock = 1 MHz, clear counter
  LPC_SCT->CTRL_L |= SCT_CTRL_PRE_L(SystemCoreClock/1000000-1) | SCT_CTRL_CLRCTR_L;
  sct_fsm_init();
  NVIC_EnableIRQ(SCT_IRQn);

// init PIO0_3 pin interrupt for wakeup from sleep mode
  Chip_SYSCTL_SetPinInterrupt(IR_IRQ,IR_PIN);
  Chip_PININT_EnableIntLow(LPC_PININT, PININTCH(IR_IRQ));
  NVIC_EnableIRQ(PININT3_IRQn);
  Chip_SYSCTL_EnablePINTWakeup(IR_IRQ);

// set sleep options
  Chip_SYSCTL_SetDeepSleepPD(SYSCTL_DEEPSLP_BOD_PD | SYSCTL_DEEPSLP_WDTOSC_PD);
  Chip_SYSCTL_SetWakeup(~(SYSCTL_SLPWAKE_IRCOUT_PD | SYSCTL_SLPWAKE_IRC_PD | SYSCTL_SLPWAKE_FLASH_PD ));

  LCDPutStr("kbiva.wordpress.com", MAX_X / 2 + 50, 10, WHITE, BLACK);
  LCDPutStr("RC5 Decoder", MAX_X / 2 + 35, 35, WHITE, BLACK);
  LCDPutStr("Frame:", MAX_X / 2 + 20, 1, WHITE, BLACK);
  LCDPutStr("System:", MAX_X / 2 + 5 , 1, WHITE, BLACK);
  LCDPutStr("Cmd:", MAX_X / 2 - 10, 1, WHITE, BLACK);
  LCDPutStr("Toggle:", MAX_X / 2 - 25, 1, WHITE, BLACK);
  LCDPutStr("Count:", MAX_X / 2 - 40, 1, WHITE, BLACK);

  while (1) {

// put chip to sleep
    switch(mcupower) {
      case PMU_MCU_SLEEP:
      default:
        LCDPutStr("SLEEP     ", MAX_X / 2 - 60, 10, WHITE, BLACK);
        Chip_PMU_SleepState(LPC_PMU);
        break;
      case PMU_MCU_DEEP_SLEEP:
        LCDPutStr("DEEP-SLEEP", MAX_X / 2 - 60, 10, WHITE, BLACK);
        Chip_PMU_DeepSleepState(LPC_PMU);
        break;
      case PMU_MCU_POWER_DOWN:
        LCDPutStr("POWER-DOWN", MAX_X / 2 - 60, 10, WHITE, BLACK);
        Chip_PMU_PowerDownState(LPC_PMU);
        break;
    }

// start MRT timer channel 0
    Chip_MRT_SetInterval(LPC_MRT_CH0, SystemCoreClock | MRT_INTVAL_LOAD);
    Chip_MRT_SetMode(LPC_MRT_CH0,MRT_MODE_ONESHOT);
    Chip_MRT_SetEnabled(LPC_MRT_CH0);

// turn on onboard LED
    Chip_GPIO_SetPinState(LPC_GPIO_PORT,0,LED_PIN,false);

// start SCT
    LPC_SCT->CTRL_L &= ~SCT_CTRL_HALT_L;

// wait for timeout
    while(!RC5_timeout)
    {};

// stop SCT
    LPC_SCT->CTRL_L |= SCT_CTRL_HALT_L;

    if (RC5_flag) {
      // if frame received, output information on LCD

      if((RC5_System != RC5_System_prev) || (RC5_Command != RC5_Command_prev)) {
        cnt = 1;
      }
      else {
        cnt++;
      }

      for (i = 3; i >= 0; i--){

        LCDPutChar(ascii[(RC5_Frame >> (i * 4)) & 0x0F],MAX_X / 2 + 20,80+(3-i)*7,WHITE, BLACK);
        if(i < 2) {
          if((RC5_System!=RC5_System_prev) || (RC5_Command!=RC5_Command_prev)){
            LCDPutChar(ascii[(RC5_System >> (i * 4)) & 0x0F],MAX_X / 2 + 5,66+(3-i)*7,WHITE, BLACK);
            LCDPutChar(ascii[(RC5_Command >> (i * 4)) & 0x0F],MAX_X / 2 - 10,66+(3-i)*7,WHITE, BLACK);
          }
        }
        LCDPutChar(ascii[(cnt >> (i * 4)) & 0x0F],MAX_X / 2 - 40,80+(3-i)*7,WHITE, BLACK);
      }

      LCDPutStr(RC5_Toggle ? "ON ":"OFF", MAX_X / 2 - 25, 80, WHITE, BLACK);

      switch(RC5_Command) {
        case 0x50:
          mcupower = PMU_MCU_SLEEP;
        break;
        case 0x55:
          if(RC5_Toggle){
            spi0Transfer(SLEEPOUT);
            spi0Transfer(DISPON);
          }
          else {
            spi0Transfer(DISPOFF);
            spi0Transfer(SLEEPIN);
          }
        break;
        case 0x56:
          mcupower = PMU_MCU_DEEP_SLEEP;
        break;
        case 0x6B:
          mcupower = PMU_MCU_POWER_DOWN;
        break;
      }

      RC5_System_prev = RC5_System;
      RC5_Command_prev = RC5_Command;
    }
// turn off onboard LED
    Chip_GPIO_SetPinState(LPC_GPIO_PORT,0,LED_PIN,true);
// clear flags
    RC5_flag = 0;
    RC5_timeout = 0;
  }
예제 #15
0
void erase_temperatura(){
	//lcd_fill_rectangle(T_Y+DIGIT_SIZE*( sizeof(temperatura)-1 ) , T_X, 132, T_X+DIGIT_SIZE, WHITE);
	LCDPutStr( "     ", T_X, T_Y+DIGIT_SIZE*( sizeof(temperatura)-1 ), BLACK, WHITE);
}
예제 #16
0
void erase_humidade(){
	//lcd_fill_rectangle(HUM_Y+DIGIT_SIZE*( sizeof(humidade)-1 ) , HUM_X, 132, 132, WHITE);
	LCDPutStr( "     ", HUM_X, HUM_Y+DIGIT_SIZE*( sizeof(humidade)-1 ), BLACK, WHITE);
}
예제 #17
0
void displayMenu_corrente(){
	LCDPutStr( (char *)corrente, I_X, I_Y, BLACK, WHITE);
}