Esempio n. 1
0
static void appTaskCanReceive(void *pdata) {
  uint8_t error;
  canMessage_t msg;
  
  /* Install the CAN interrupt handler and start the OS ticker
   * (must be done in the highest priority task)
   */
  canRxInterrupt(canHandler);
  osStartTick();

  /* 
   * Now execute the main task loop for this task
   */     
  while ( true ) {
    OSSemPend(can1RxSem, 0, &error);
    msg = can1RxBuf;
    interfaceLedToggle(D1_LED);
    OSMutexPend(displayMutex, 0, &error);
    lcdSetTextPos(2,1);
    lcdWrite("ID     : %08x", msg.id); 
    lcdSetTextPos(2,2);
    lcdWrite("LEN    : %08x", msg.len); 
    lcdSetTextPos(2,3);
    lcdWrite("DATA_A : %08x", msg.dataA); 
    lcdSetTextPos(2,4);
    lcdWrite("DATA_B : %08x", msg.dataB); 
    error = OSMutexPost(displayMutex);
  }
}
Esempio n. 2
0
void lcdPrintInt(int inum, char width) {
	char len = (inum == 0? 1 : (ilog10(inum) + 1));
	int i;
	for(i = 0; i < width - len; i++)
		lcdWrite('0', 1, 1);
	for(i = ipow10(len - 1); i > 0; inum %= i, i /= 10, len--)
			lcdWrite('0' + inum/i, 1, 1);
}
void lcdCreateCustomCharacter(
  byte identifier,
  const char bitMap[8]) {

  lcdWrite(LCD_COMMAND_CUSTOM_CHARACTER + (identifier << 3), false);
  for (byte index = 0;  index < 8;  index ++) lcdWrite(bitMap[index], true);
  lcdWrite(LCD_COMMAND_SET_DDRAM_ADDRESS, false);
}
Esempio n. 4
0
int lcdInit(void)		/* Initializes the display on the LCD shield, returns 1 if everything is ok */
{
	int all_ok=1;		/* at the beginning assume nothing works */
	
	/* At power on */
	ioport_set_pin_dir(LCD_RS, IOPORT_DIR_OUTPUT);
	ioport_set_pin_dir(LCD_Enable, IOPORT_DIR_OUTPUT);
	ioport_set_port_dir(IOPORT_PIOC, LCD_mask_D4_D7, IOPORT_DIR_OUTPUT);
	ioport_set_pin_level(LCD_Enable, LOW);
	delayMicroseconds(30000);		/* wait > 15 ms */
	ioport_set_pin_level(LCD_RS, LOW);
	
	/* Function set (interface is 8 bit long) */
	ioport_set_pin_level(LCD_D4, HIGH);
	ioport_set_pin_level(LCD_D5, HIGH);
	ioport_set_pin_level(LCD_D6, LOW);
	ioport_set_pin_level(LCD_D7, LOW);
	ioport_set_pin_level(LCD_Enable, HIGH);
	delayMicroseconds(1);		/* wait 1 us */
	ioport_set_pin_level(LCD_Enable, LOW);
	delayMicroseconds(4100);	/* wait for more than 4,1 ms */
	ioport_set_pin_level(LCD_D4, HIGH);
	ioport_set_pin_level(LCD_D5, HIGH);
	ioport_set_pin_level(LCD_D6, LOW);
	ioport_set_pin_level(LCD_D7, LOW);
	ioport_set_pin_level(LCD_Enable, HIGH);
	delayMicroseconds(1);	/* delay 1 us */
	ioport_set_pin_level(LCD_Enable, LOW);
	delayMicroseconds(100);	/* wait 100 us */
	ioport_set_pin_level(LCD_D4, HIGH);
	ioport_set_pin_level(LCD_D5, HIGH);
	ioport_set_pin_level(LCD_D6, LOW);
	ioport_set_pin_level(LCD_D7, LOW);
	ioport_set_pin_level(LCD_Enable, HIGH);
	delayMicroseconds(1);	/* wait 1 us */
	ioport_set_pin_level(LCD_Enable, LOW);		
	delayMicroseconds(100);	/* wait 100 us */
		
	/* Set display to 4-bit input */
	ioport_set_pin_level(LCD_D4, LOW);
	ioport_set_pin_level(LCD_D5, HIGH);
	ioport_set_pin_level(LCD_D6, LOW);
	ioport_set_pin_level(LCD_D7, LOW);
	ioport_set_pin_level(LCD_Enable, HIGH);
	delayMicroseconds(1);
	ioport_set_pin_level(LCD_Enable, LOW);
	delayMicroseconds(100);
	lcdWrite(0b00101000, LOW);		/* Two rows, small font */
	lcdWrite(0b00001000, LOW);		/* Display off */
	lcdWrite(0b00000001, LOW);		/* Display clear */
	delayMicroseconds(3000);
	lcdWrite(0b00000110, LOW);		/* Entry mode set: move cursor right, no display shift */
	lcdWrite(0b00001111 ,LOW);		/* Display on, cursor on, blinking on */

	all_ok = 0;					/* simple return statement showing that the initialization of the LCD has completed */
	return all_ok;
}
Esempio n. 5
0
void lcdInit(void) {
	SETUPgout(LCD_BL_EN);
	SETUPgout(LCD_RESET);
	SETUPgout(LCD_CS);

	/* prepare SPI */
	SETUPpin(LCD_MOSI);
	SETUPpin(LCD_SCK);

	// Reset the display
    OFF(LCD_RESET);
    delayms(100); /* 1 ms */
    ON(LCD_RESET);
    delayms(100); /* 5 ms */

    lcd_select();

	static uint8_t initseq_d[] = {
		/* The controller is a PCF8833 -
		   documentation can be found online.
		 */
		0x11,              // SLEEP_OUT  (wake up)
		0x3A, 2,           // mode 8bpp  (2= 8bpp, 3= 12bpp, 5= 16bpp)
		0x36, 0b11000000,  // my,mx,v,lao,rgb,x,x,x
		0x25, 0x3a,        // set contrast
		0x29,              // display on 
		0x03,              // BSTRON (booster voltage)
		0x2A, 1, RESX,
		0x2B, 1, RESY
	};
	uint16_t initseq_c = ~  (  /* commands: 1, data: 0 */
			(1<< 0) |
			(1<< 1) | (0<< 2) |
			(1<< 3) | (0<< 4) |
			(1<< 5) | (0<< 6) |
			(1<< 7) |
			(1<< 8) |
			(1<< 9) | (0<<10) | (0<<11) |
			(1<<12) | (0<<13) | (0<<14) |
			0);
	int i = 0;

	lcdWrite(0, 0x01); /* most color displays need the pause */
	delayms(10);

	while(i<sizeof(initseq_d)){
		lcdWrite(initseq_c&1, initseq_d[i++]);
		initseq_c = initseq_c >> 1;
	}
    lcd_deselect();
	lcdFill(0xff); /* Clear display buffer */
	setSystemFont();
}
Esempio n. 6
0
void lcdDisplay(void) {
    lcd_select();

	uint16_t x,y;

	lcdWrite(TYPE_CMD,0x2C); // memory write (RAMWR)

	for(y=0;y<RESY;y++){
		for(x=0;x<RESX;x++){
			lcdWrite(TYPE_DATA,lcdGetPixel(x,y)); 
		};
	}
    lcd_deselect();
}
Esempio n. 7
0
//==============================================================================
void ICACHE_FLASH_ATTR tft_fillRect(unsigned int x, unsigned int y,
                  unsigned int w, unsigned int h, 
                  unsigned long color)
{
	// rudimentary clipping (drawChar w/big text requires this)
	if((x >= _width) || (y >= _height)) return;
	if((x + w - 1) >= _width)  w = _width  - x;
	if((y + h - 1) >= _height) h = _height - y;

	// TODO: this can result in a very long transaction time
	// should break this into multiple transactions, even though
	// it'll cost more overhead, so we don't stall other SPI libs
	//SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0));
	LCD_setAddr(x, y, x+w-1, y+h-1);
	lcdWrite(COMMAND, RAMWR);
	for(y=h; y>0; y--) {
		for(x=w; x>0; x--) {
			setPixel(color);
		}
		//setPixel(color);
//		if (y > 1 && (y & 1)) {
//			SPI.endTransaction();
//			SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0));
//		}
	}
//	SPI.endTransaction();
}
Esempio n. 8
0
//***************************************************************************
// Name: lcdDataWrite
//
// Description: Write data to the LCD controller.
//
// Parameters: lcdD - Data byte to write.
//
// Returns: None.
//
// Comments: RS line is set to high.
//
//***************************************************************************
void lcdDataWrite(char lcdD)
{
	// RS high for data write
	PORT_LCD_RS = LCD_DATA;

	lcdWrite(lcdD);
}
Esempio n. 9
0
//***************************************************************************
// Name: lcdInsWrite
//
// Description: Write an instruction code to the LCD controller.
//
// Parameters: lcdI - Instruction byte to write.
//
// Returns: None.
//
// Comments: RS line is set to low.
//
//***************************************************************************
void lcdInsWrite(char lcdI)
{
	// RS low for instruction write
	PORT_LCD_RS = LCD_INS;

	lcdWrite(lcdI);
}
Esempio n. 10
0
void lcdPrintStr(char * printdat)
{
	 while(*printdat)
	 {
	  	lcdWrite(*(printdat++),1,1);
	 }
}
Esempio n. 11
0
void lcdFlashPrint(const char *FlashLoc)
{
	BYTE i;
	for(i=0;(BYTE)pgm_read_byte(&FlashLoc[i]);i++) {
		lcdWrite((BYTE)pgm_read_byte(&FlashLoc[i]), 1);
	}
}
Esempio n. 12
0
void lcdInit()
{
	DAT_PORT&=~0xf0;
//	if(en_bkl) CON_PORT&=~(1<<BKL);
//	else CON_PORT|=(1<<BKL);
	CON_DDR|=((1<<RS)|(1<<RW)|(1<<EN)|(1<<BKL));
	lcdWrite(0x28,0,0);//4位数据接口 两行 5*7点阵
	_delay_ms(4);
	lcdWrite(0x28,0,0);
	_delay_ms(4);
	lcdWrite(0x28,0,1);
	_delay_ms(4);
	lcdWrite(0x0e,0,1);//开显示,无光标,不闪烁。0x0c 0x0f
	_delay_ms(4);
	lcdWrite(0x06,0,1);//输入设置,AC自增,位置不动
	lcdClear();
}
Esempio n. 13
0
/***********************************************************************************
 * @fn          halLcdClear
 *
 * @brief       Clear all lines on display
 *
 * @param       none
 *
 * @return      none
 */
void halLcdClear(void)
{
    uint8 n;
    SET_DDRAM_ADDR(0x00);
    for (n = 0; n < (LCD_LINE_COUNT * LCD_LINE_LENGTH); n++) {
        lcdWrite(' ');
    }
}
Esempio n. 14
0
File: hal_lcd.c Progetto: gxp/node
/***********************************************************************************
 * @fn          halLcdCreateSpecChar
 *
 * @brief       Create special character
 *
 * @param       uint8 index
 *              const char *p5x8Spec
 *
 * @return      none
 */
void halLcdCreateSpecChar(uint8 index, const char *p5x8Spec)
{
    uint8 n;
    SET_GCRAM_CHAR(index);
    for (n = 0; n < 8; n++) {
        lcdWrite(p5x8Spec[n]);
    }
}
Esempio n. 15
0
File: hal_lcd.c Progetto: gxp/node
/***********************************************************************************
 * @fn          halLcdClearAllSpecChars
 *
 * @brief       Clear special characters
 *
 * @param       none
 *
 * @return      none
 */
void halLcdClearAllSpecChars(void)
{
    uint8 n;
    SET_GCRAM_CHAR(0);
    for (n = 0; n < (8 * 8); n++) {
        lcdWrite(0x00);
    }
}
Esempio n. 16
0
File: lcd.cpp Progetto: Schurick/pi
void lcdWriteText(unsigned char* data){
	int i;
	size_t len;

	for(i=0; i < strlen((const char *)data); i++){
		lcdWrite(DATA,data[i]);
	}
}
Esempio n. 17
0
void lcdLocate(unsigned char lx,unsigned char ly) //(x, y)
{
	 unsigned char locdat;
	 if(ly) locdat=0x40;
	 else locdat=0;
	 locdat=locdat+lx;
	 locdat|=0x80;
	 lcdWrite(locdat,0,1);
}
Esempio n. 18
0
void showLogo(void)
{
	lcdClear();

  	for ( int i = 0; i < ( 84 * 48 ) / 8; i++)
  	{
    	lcdWrite(LCD_DATA, logo[i]);
  	}
}
Esempio n. 19
0
/**
 * Prints character to LCD with support for character wrapping
 * 
 * Inputs:	db		character to print
 */
static void lcdPrint(char db) {
    if (pos==16) lcdGoTo(1, 0);
    if (pos==32) lcdGoTo(2, 0);
    if (pos==48) lcdGoTo(3, 0);
    if (pos==64) lcdGoTo(0, 0);

    lcdWrite(db, 1);
    pos++;
}
Esempio n. 20
0
//==============================================================================
void ICACHE_FLASH_ATTR drawPixel( int x,  int y,  long color) {

	if((x < 0) ||(x >= _width) || (y < 0) || (y >= _height)) return;

	//SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0));
	LCD_setAddr(x, y, x, y);
	lcdWrite(COMMAND, RAMWR);//writecommand_cont(ILI9341_RAMWR);
	setPixel(color);//writedata16_last(color);
	//SPI.endTransaction();
}
Esempio n. 21
0
/**
 * Initializes LCD
 */
void lcdInit() {

    LCD_CTRL_DDR = _BV(LCD_RS_PIN)|_BV(LCD_RW_PIN)|_BV(LCD_EN_PIN);

    delay_us(LCD_DELAY_START);

    lcdWrite(LCD_CMD_FUNCTION, 0);
	lcdBusyWait();

    lcdWrite(LCD_CMD_DISP, 0);
	lcdBusyWait();
	
    lcdClear();

    lcdWrite(LCD_CMD_ENTRY, 0);
	lcdBusyWait();

    /* printf */
    fdevopen((void*)lcdPrint, 0);
}
Esempio n. 22
0
static void appTaskCANRead(void *pdata) {
  
  canRxInterrupt(canHandler);    // configure CAN to interrupt on message reception
  
  while ( true ) {
    if (can2RxDone) {           // could be handled better with a semaphore
      can2RxDone = false;
      lcdSetTextPos(2,1);
      lcdWrite("ID    : %x", can2RxBuffer.id); 
      lcdSetTextPos(2,2);
      lcdWrite("LEN   : %x", can2RxBuffer.len); 
      lcdSetTextPos(2,3);
      lcdWrite("DATA_A: %x", can2RxBuffer.dataA); 
      lcdSetTextPos(2,4);
      lcdWrite("DATA_B: %x", can2RxBuffer.dataB); 
      rxCount += 1;
    }
    OSTimeDly(100);
  }
}
Esempio n. 23
0
void lcdPrintFloat(float fnum, char width, short prec) {
	long i , j;
	char len;

	if(fnum < 0) {
		lcdWrite('-', 1, 1);
		i = -fnum;
	} else {
		i = fnum;
	}
	len = (i == 0 ? 1 : (ilog10(i) + 1)) + prec;
	i = fnum * ipow10(prec);
	for(j = 0; j < width - len - (prec != 0); j++)
		lcdWrite('0', 1, 1);
	for(j = ipow10(len - 1); j > 0; i %= j, j /= 10, len--) {
		lcdWrite('0' + i/j, 1, 1);
		if(prec > 0 && len - 1 == prec)
			lcdWrite('.', 1, 1);
	}
}
Esempio n. 24
0
static void appTaskCanMonitor(void *pdata) {
  uint8_t error;
  
  while (true) {
    OSMutexPend(displayMutex, 0, &error);
    lcdSetTextPos(2,5);
    lcdWrite("CAN1GSR: %08x", canStatus(CAN_PORT_1));
    error = OSMutexPost(displayMutex);
    OSTimeDly(20);
  }
}
Esempio n. 25
0
/**
 * Moves cursor to a specified row and column starting at (0,0).
 * No checking of row and col are performed.
 * 
 * Inputs: 	row		row of lcd ( 0 <= row <= 3 )
 *			col		column of lcd ( 0 <= col <= 15 )
 */
void lcdGoTo(int row, int col) {
    switch ( row ) {
    case 0:
        lcdWrite(0x80 | (col + LCD_ADR_LINE0), 0);
        break;
    case 1:
        lcdWrite(0x80 | (col + LCD_ADR_LINE1), 0);
        break;
    case 2:
        lcdWrite(0x80 | (col + LCD_ADR_LINE2), 0);
        break;
    case 3:
        lcdWrite(0x80 | (col + LCD_ADR_LINE3), 0);
        break;
    default:
        /* default write to first row */
        lcdWrite(0x80 | (col + LCD_ADR_LINE0), 0);
    }

    pos = (row*16) + col;
}
Esempio n. 26
0
void lcdPosition(
  byte row,        // Must be either 0 (first row) or 1 (second row)
  byte column) {   // Must be between 0 and 19

  if (row > 1) {
    row    -= 2;
    column += 20;
  }
  if (row == 1) row = LCD_SECOND_ROW;
  lcdWrite(LCD_COMMAND_SET_DDRAM_ADDRESS | row | column, false);
  delayMicroseconds(40);
}
Esempio n. 27
0
void test_timer_startStop_init()
{
    lcdOnOffControl_t control;
    
    bLongTimeInsteadOfShort = FALSE;
    lcdClear();
    control.bBlinkingCursor = FALSE;
    control.bCursorOn = FALSE;
    control.bLcdOn = TRUE;
    lcdOnOffControl(control);
    
    lcdWrite("<timer test>");
}
Esempio n. 28
0
void gotoErrorState(char* strError)
{
  // write error on lcd
  lcdClear();
  lcdWrite(strError);

  //todo: wait 3s and than reset, use watchdog


  while(1)
    {

    }
}
Esempio n. 29
0
//==============================================================================
void ICACHE_FLASH_ATTR tft_drawFastHLine(unsigned int x, unsigned int y, unsigned int w, unsigned long color)
{
	// Rudimentary clipping
	if((x >= _width) || (y >= _height)) return;
	if((x+w-1) >= _width)  w = _width-x;
	//SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0));
	LCD_setAddr(x, y, x+w-1, y);
	lcdWrite(COMMAND, RAMWR);//writecommand_cont(ILI9341_RAMWR);
	while (w-- > 0) {
		setPixel(color);//writedata16_cont(color);
	}
//	writedata16_last(color);
//	SPI.endTransaction();
}
Esempio n. 30
0
void lcd4096Initialize(void) {
  pinMode(PIN_LCD_CLOCK,  OUTPUT);
  pinMode(PIN_LCD_DATA,   OUTPUT);
  pinMode(PIN_LCD_STROBE, OUTPUT);

  byte length = sizeof(lcdSetup) / sizeof(*lcdSetup);
  byte index = 0;

  while (index < length) {
    lcdWrite(lcdSetup[index ++], false);
    delay(lcdSetup[index ++]);
  }

  lcdCreateCustomCharacter(7, bitmapBackslash);         // last custom character

  lcd4096Initialized = true;
}