void set_orientation(orientation o) { display.orient = o; write_cmd(MEMORY_ACCESS_CONTROL); if (o==North) { display.width = LCDWIDTH; display.height = LCDHEIGHT; write_data(0x48); } else if (o==West) { display.width = LCDHEIGHT; display.height = LCDWIDTH; write_data(0xE8); } else if (o==South) { display.width = LCDWIDTH; display.height = LCDHEIGHT; write_data(0x88); } else if (o==East) { display.width = LCDHEIGHT; display.height = LCDWIDTH; write_data(0x28); } write_cmd(COLUMN_ADDRESS_SET); write_data16(0); write_data16(display.width-1); write_cmd(PAGE_ADDRESS_SET); write_data16(0); write_data16(display.height-1); }
/*********************************************************** * 函数名称: * 功能描述: OLED设置坐标 * 参数列表: * 返回结果: * 备 注: ***********************************************************/ void OLED_SSD1306:: set_xy(uint16_t x, uint16_t y) { write_cmd(0xb0 + y); write_cmd(((x & 0xf0) >> 4) | 0x10); write_cmd((x & 0x0f) | 0x01); }
void ili9341fb_set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye) { uint8_t xsl, xsh, xel, xeh, ysl, ysh, yel, yeh; u16 *p = (u16 *)par->buf; int i = 0; fbtft_dev_dbg(DEBUG_SET_ADDR_WIN, par->info->device, "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n", __func__, xs, ys, xe, ye); xsl = (uint8_t)(xs & 0xff); xsh = (uint8_t)((xs >> 8) & 0xff); xel = (uint8_t)(xe & 0xff); xeh = (uint8_t)((xe >> 8) & 0xff); ysl = (uint8_t)(ys & 0xff); ysh = (uint8_t)((ys >> 8) & 0xff); yel = (uint8_t)(ye & 0xff); yeh = (uint8_t)((ye >> 8) & 0xff); write_cmd(par, FBTFT_CASET); write_data(par, xsh); write_data(par, xsl); write_data(par, xeh); write_data(par, xel); write_cmd(par, FBTFT_RASET); write_data(par, ysh); write_data(par, ysl); write_data(par, yeh); write_data(par, yel); write_cmd(par, FBTFT_RAMWR); write_flush(par); }
static int32_t conax_do_emm(struct s_reader * reader, EMM_PACKET *ep) { def_resp; unsigned char insCA[] = { 0xDD,0xCA,0x00,0x00,0x00 }; unsigned char insEMM[] = { 0xDD,0x84,0x00,0x00,0x00 }; unsigned char buf[255]; int32_t rc=0; const int32_t l = ep->emm[2]; insEMM[4]=l+5; buf[0]=0x12; buf[1]=l+3; memcpy(buf+2, ep->emm, buf[1]); write_cmd(insEMM, buf); if (cta_res[0] == 0x98) { insCA[4] = cta_res[1]; write_cmd(insCA, NULL); } rc=((cta_res[0]==0x90)&&(cta_res[1]==0x00)); if (rc) return OK; else return ERROR; }
void display_char(char c) { uint16_t x, y; PGM_P fdata; uint8_t bits, mask; uint16_t sc=display.x, ec=display.x + 4, sp=display.y, ep=display.y + 7; if (c < 32 || c > 126) return; fdata = (c - ' ')*5 + font5x7; write_cmd(PAGE_ADDRESS_SET); write_data16(sp); write_data16(ep); for(x=sc; x<=ec; x++) { write_cmd(COLUMN_ADDRESS_SET); write_data16(x); write_data16(x); write_cmd(MEMORY_WRITE); bits = pgm_read_byte(fdata++); for(y=sp, mask=0x01; y<=ep; y++, mask<<=1) write_data16((bits & mask) ? display.foreground : display.background); } write_cmd(COLUMN_ADDRESS_SET); write_data16(x); write_data16(x); write_cmd(MEMORY_WRITE); for(y=sp; y<=ep; y++) write_data16(display.background); display.x += 6; if (display.x >= display.width) { display.x=0; display.y+=8; } }
LLDSPEC void gdisp_lld_flush(GDisplay *g) { uint8_t * ram; unsigned pages; // Don't flush if we don't need it. if (!(g->flags & GDISP_FLG_NEEDFLUSH)) return; ram = RAM(g); pages = GDISP_SCREEN_HEIGHT/8; acquire_bus(g); write_cmd(g, SSD1306_SETSTARTLINE | 0); while (pages--) { #if SSD1306_SH1106 write_cmd(g, SSD1306_PAM_PAGE_START + (7 - pages)); write_cmd(g, SSD1306_SETLOWCOLUMN + 2); write_cmd(g, SSD1306_SETHIGHCOLUMN); #endif write_data(g, ram, SSD1306_PAGE_WIDTH); ram += SSD1306_PAGE_WIDTH; } release_bus(g); g->flags &= ~GDISP_FLG_NEEDFLUSH; }
void tdisp_lld_control(uint16_t what, void *value) { switch(what) { case TDISP_CTRL_BACKLIGHT: if ((uint8_t)value) displaycontrol |= DISPLAY_ON; else displaycontrol &= ~DISPLAY_ON; write_cmd(0x08 | displaycontrol); break; case TDISP_CTRL_CURSOR: switch((cursorshape)value) { case cursorOff: displaycontrol &= ~CURSOR_ON; break; case cursorBlock: case cursorUnderline: case cursorBar: displaycontrol = (displaycontrol | CURSOR_ON) & ~CURSOR_BLINK; break; case cursorBlinkingBlock: case cursorBlinkingUnderline: case cursorBlinkingBar: default: displaycontrol |= (CURSOR_ON | CURSOR_BLINK); break; } write_cmd(0x08 | displaycontrol); break; } }
//关闭OLED显示 void OLED_Display_Off(void) { write_cmd(0X8D); //SET DCDC命令 write_cmd(0X10); //DCDC OFF write_cmd(0XAE); //DISPLAY OFF Set_OLED_VDD; Set_OLED_VBAT; }
void goxy(unsigned char y,unsigned char x) { if(y==1) write_cmd(0x80|x); if(y==2) write_cmd(x-(0x40)); }
static int blank(struct fbtft_par *par, bool on) { fbtft_dev_dbg(DEBUG_BLANK, par->info->device, "%s(blank=%s)\n", __func__, on ? "true" : "false"); if (on) write_cmd(par, 0xAE); else write_cmd(par, 0xAF); return 0; }
void lcd_l602init()//1602初始化 { EN=0; write_cmd(0x38);//设置16*2显示 write_cmd(0x0c);//显示器开,光标开 write_cmd(0x06);//写一个字符后地址加1 write_cmd(0x01);//显示清0,DPTR清0 }
/* Write display control commands to the display */ void tdisp_lld_control(uint16_t what, uint16_t value) { switch(what) { case TDISP_CTRL_DISPLAY: switch (value) { case displayOff: displaycontrol &= ~TDISP_DISPLAY_ON; break; case displayOn: displaycontrol |= TDISP_DISPLAY_ON; break; } write_cmd(0x08 | displaycontrol); break; case TDISP_CTRL_CURSOR: switch (value) { case cursorBlinkingBlock: case cursorBlinkingUnderline: case cursorBlinkingBar: displaycontrol |= TDISP_CURSOR_ON + TDISP_CURSOR_BLINK; break; case cursorBlock: case cursorUnderline: case cursorBar: displaycontrol = (displaycontrol | TDISP_CURSOR_ON) & ~TDISP_CURSOR_BLINK; break; case cursorOff: default: displaycontrol &= ~(TDISP_CURSOR_ON | TDISP_CURSOR_BLINK); // zet alleen de cursor uit. Bewaar de overige instellingen break; } write_cmd(0x08 | displaycontrol); break; case TDISP_CTRL_MOVE: switch (value) { case cursorIncrease: cursorcontrol |= TDISP_CURSOR_INC; // increase cursor position break; case cursorDecrease: cursorcontrol &= ~TDISP_CURSOR_INC; // decrease cursor position break; } write_cmd(0x04 | cursorcontrol); break; case TDISP_CTRL_SHIFT: switch (value) { case shiftOn: cursorcontrol |= TDISP_SHIFT_ON; break; case shiftOff: cursorcontrol &= ~TDISP_SHIFT_ON; break; } write_cmd(0x04 | cursorcontrol); break; } }
/*----------------------------------------------------------------------- LCD_clear : LCD清屏函数 -----------------------------------------------------------------------*/ void NOKIA5110::clear(void) { unsigned int i = 0; write_cmd(0x0c); write_cmd(0x80); for (i=0; i<504; i++) write_data(0); }
/*LCD?????*/ void lcd_init() { LCD_PSB=1; write_cmd(0x30); delay_1ms(5); write_cmd(0x0C); delay_1ms(5); write_cmd(0x01); delay_1ms(5); }
LLDSPEC void gdisp_lld_write_start(GDisplay *g) { acquire_bus(g); write_cmd(g, SSD1327_SET_COLUMN_ADDRESS); write_data(g, g->p.x); write_data(g, g->p.x + g->p.cx - 1); write_cmd(g, SSD1327_SET_ROW_ADDRESS); write_data(g, g->p.y); write_data(g, g->p.y + g->p.cy - 1); write_cmd(g, SSD1327_WRITE_RAM); }
void nokia_lcd_render(void) { register unsigned i; /* Set column and row to 0 */ write_cmd(0x80); write_cmd(0x40); /* Write screen to display */ for (i = 0; i < 504; i++) write_data(nokia_lcd.screen[i]); }
//更新显存到LCD void OLED_Refresh_Gram(void) { u8 i,n; for(i=0;i<8;i++) { write_cmd (0xb0+i); //设置页地址(0~7) write_cmd (0x02); //设置显示位置—列低地址,偏移了2列 write_cmd (0x10); //设置显示位置—列高地址 for(n=0;n<128;n++)write_data(OLED_GRAM[n][i]); } }
/*********************************************************** * 函数名称: * 功能描述: OLED清屏 * 参数列表: * 返回结果: * 备 注:清屏函数,清完屏,整个屏幕是黑色的!和没点亮一样!!! ***********************************************************/ void OLED_SSD1306::clear(void) { uint8_t i, n; for(i = 0; i < 8; i++) { write_cmd(0xb0 + i); //设置也地址(0~7) write_cmd (0x00); //设置显示位置—列低地址 write_cmd (0x10); //设置显示位置—列高地址 for(n = 0; n < 128; n++)write_data(0); } //更新显示 }
static void gdisp_lld_display(void) { uint8_t p; set_display_start_line(0); for (p = 0; p < 8; p++) { write_cmd(ST7565_PAGE | p); write_cmd(ST7565_COLUMN_MSB | 0); write_cmd(ST7565_COLUMN_LSB | 0); write_cmd(ST7565_RMW); write_data(&gdisp_buffer[p * GDISP_SCREEN_WIDTH], GDISP_SCREEN_WIDTH); } }
void nokia_lcd_clear(void) { register unsigned i; /* Set column and row to 0 */ write_cmd(0x80); write_cmd(0x40); /*Cursor too */ nokia_lcd.cursor_x = 0; nokia_lcd.cursor_y = 0; /* Clear everything (504 bytes = 84cols * 48 rows / 8 bits) */ for(i = 0;i < 504; i++) nokia_lcd.screen[i] = 0x00; }
/** * get coordinates * @return 1 if all OK */ int get_telescope_coords(double *ra, double *decl){ double r, d; char *ans; // :GR# -> 11:05:26.16# ans = write_cmd(":GR#"); if(!str2coord(ans, &r)) return 0; // :GD# -> +44:14:10.7# ans = write_cmd(":GD#"); if(!str2coord(ans, &d)) return 0; if(ra) *ra = r; if(decl) *decl = d; return 1; }
// FIXME: write to stout void write_results(Solver *self, bool solved) { // TODO: add number of iterations FILE *f = fopen("result.csp.bin", "wb"); CommandData h = { CMD_RESULT, solved, self->n_variables, 0 }; write_cmd(f, &h); for (int i=0; i<self->n_variables; i++) { CommandData r = { CMD_VALUE, (i+1), self->values[i], 0 }; write_cmd(f, &r); } fclose(f); }
void fill_rectangle_indexed(rectangle r, uint16_t* col) { uint16_t x, y; write_cmd(COLUMN_ADDRESS_SET); write_data16(r.left); write_data16(r.right); write_cmd(PAGE_ADDRESS_SET); write_data16(r.top); write_data16(r.bottom); write_cmd(MEMORY_WRITE); for(x=r.left; x<=r.right; x++) for(y=r.top; y<=r.bottom; y++) write_data16(*col++); }
void ssd1351fb_set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye) { fbtft_fbtft_dev_dbg(DEBUG_SET_ADDR_WIN, par, par->info->device, "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n", __func__, xs, ys, xe, ye); write_cmd(par, 0x15); write_data(par, xs); write_data(par, xe); write_cmd(par, 0x75); write_data(par, ys); write_data(par, ye); write_cmd(par, 0x5c); }
static int32_t read_record(struct s_reader * reader, const uchar *cmd, const uchar *data, uchar * cta_res) { uint16_t cta_lr; uchar insCA[] = {0xDD, 0xCA, 0x00, 0x00, 0x00}; write_cmd(cmd, data); // select record if (cta_res[0]!=0x98) return(-1); insCA[4]=cta_res[1]; // get len write_cmd(insCA, NULL); // read record if ((cta_res[cta_lr-2]!=0x90) || (cta_res[cta_lr-1])) return(-1); return(cta_lr-2); }
static int32_t unlock_parental(struct s_reader * reader) { /* disabling parental lock. assuming pin "0000" if no pin code is provided in the config */ static const uchar inDPL[] = {0xca, 0x24, 0x02, 0x00, 0x09}; uchar cmDPL[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F}; def_resp; if (strcmp(reader->pincode, "none")) { rdr_log(reader, "Using PIN %s",reader->pincode); // the pin need to be coded in bcd, so we need to convert from ascii to bcd, so '1234' -> 0x12 0x34 cmDPL[6]=((reader->pincode[0]-0x30)<<4) | ((reader->pincode[1]-0x30) & 0x0f); cmDPL[7]=((reader->pincode[2]-0x30)<<4) | ((reader->pincode[3]-0x30) & 0x0f); } else { rdr_log(reader, "Using PIN 0000!"); } write_cmd(inDPL,cmDPL); if( !(cta_res[cta_lr-2]==0x90 && cta_res[cta_lr-1]==0) ) { if (strcmp(reader->pincode, "none")) { rdr_log(reader, "Can't disable parental lock. Wrong PIN? OSCam used %s!",reader->pincode); } else { rdr_log(reader, "Can't disable parental lock. Wrong PIN? OSCam used 0000!"); } } else rdr_log(reader, "Parental lock disabled"); return 0; }
//Set cursor position void set_cursor(int column, int row) { int addr; addr = (row * LINE_LENGTH) + column; addr |= TOT_LENGTH; write_cmd(addr); }
void set_frame_rate_hz(uint8_t f) { uint8_t diva, rtna, period; if (f>118) f = 118; if (f<8) f = 8; if (f>60) { diva = 0x00; } else if (f>30) { diva = 0x01; } else if (f>15) { diva = 0x02; } else { diva = 0x03; } /* !!! FIXME !!! [KPZ-30.01.2015] */ /* Check whether this works for diva > 0 */ /* See ILI9341 datasheet, page 155 */ period = 1920.0/f; rtna = period >> diva; write_cmd(FRAME_CONTROL_IN_NORMAL_MODE); write_data(diva); write_data(rtna); }
void tdisp_lld_create_char(uint8_t address, uint8_t *charmap) { int i; write_cmd(0x40 | (address << 3)); for(i = 0; i < CUSTOM_CHAR_YBITS; i++) write_data(charmap[i]); }
int main(int argc, char** argv) { int fn, arg1, arg2, result; byte buff[100]; /* Part where serial port is initialized */ while(read_cmd(buff) > 0) { fn = buff[0]; if (fn == 1) { arg1 = buff[1]; result = arg1*2; } else if (fn == 2) { arg1 = buff[1]; arg2 = buff[2]; result = arg1+arg2; } buff[0] = result; write_cmd(buff, 1); } return(0); }