void routine(void) { LCDClear(); LCDBitmap(bitcoin); // display Bitcoin Logo delay(3000); LCDClear(); gotoXY(0, 4); LCDString("kendricktabi.com"); delay(3000); LCDClear(); gotoXY(0, 0); LCDString(" {Bitcoin!} "); gotoXY(0, 2); LCDString("Connecting "); LCDString("to WiFi"); LCDClear(); gotoXY(0, 2); LCDString(" WiFi "); LCDString(" Connected! "); delay(1000); LCDClear(); for(;;) { loop(); } }
static void ICACHE_FLASH_ATTR showLargeChar(const uint8 *c, uint8 charCol, uint8 charRow) { const uint8 w = 15; uint8 pxCol; gotoXY(charRow * (w + 1), 2 * (2 - charCol)); easygpio_outputSet(LCD_D_C, 1); if ('0' <= *c && *c <= '?') { for (pxCol = 0; pxCol < w; pxCol++) { spi(NUMERIC[(int) (*c - '0')][pxCol][1]); } spi(0); gotoXY(charRow * (w + 1), 2 * (2 - charCol) + 1); easygpio_outputSet(LCD_D_C, 1); for (pxCol = 0; pxCol < w; pxCol++) { spi(NUMERIC[(int) (*c - '0')][pxCol][0]); } spi(0); } else { // Space as default for (pxCol = 0; pxCol <= w; pxCol++) { spi(0); } gotoXY(charRow * (w + 1), 2 * (2 - charCol) + 1); easygpio_outputSet(LCD_D_C, 1); for (pxCol = 0; pxCol <= w; pxCol++) { spi(0); } } }
//-------------------------------------------------------------- // Purpose : Render function is to update the console screen // Input : void // Output : void //-------------------------------------------------------------- void render( void ) { // clear previous screen colour(0x0F); cls(); //render the game //render test screen code (not efficient at all) const WORD colors[] = { 0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F, 0xA1, 0xB2, 0xC3, 0xD4, 0xE5, 0xF6 }; for (int i = 0; i < 12; ++i) { gotoXY(3*i,i+1); colour(colors[i]); std::cout << "WOW"; } // render time taken to calculate this frame gotoXY(70, 0); colour(0x1A); std::cout << 1.0 / g_dDeltaTime << "fps" << std::endl; gotoXY(0, 0); colour(0x59); std::cout << g_dElapsedTime << "secs" << std::endl; // render character gotoXY(g_cCharLocation); colour(0x0C); std::cout << (char)1; }
void PCD8544::writeLargeNumber(byte c) { byte prevX = _x, prevY = _y; if(c < '.' || c > '9') { return; } for (int index = 0; index < 12; index++) { LcdWrite(LCD_DATA, pgm_read_byte(&Large_Numbers[c - '.'][index])); //LcdWrite(LCD_DATA, Large_Numbers[c - '.'][index]); } gotoXY(prevX, prevY + 1); for (int index = 12; index < 24; index++) { LcdWrite(LCD_DATA, pgm_read_byte(&Large_Numbers[c - '.'][index])); //LcdWrite(LCD_DATA, Large_Numbers[c - '.'][index]); } gotoXY(prevX + 12, prevY); }
//Clears the LCD by writing zeros to the entire screen void LCDClear(void) { int index; gotoXY(0, 0); //Make sure that we start at the home position since the LCD seems to pick up where it left off. for (index = 0 ; index < 504 ; index++) //(LCD_X * LCD_Y / 8) = 504 //Doesn't seem to work with the defined macros, but does if I hard-code the number of pixels/8 { LCDWrite(LCD_DATA, 0x00); } gotoXY(0, 0); //After we clear the display, return to the home position }
void LCDSample(void) { LCDClear(); gotoXY(7,1); LCDString("Nokia 5110"); gotoXY(4,2); LCDString("Scroll Demo"); }
void clock_end() { seconds = (clock() - start ) / (int) CLOCKS_PER_SEC ; while(seconds >= 60) { seconds -=60; minutes += 1; } if (minutes == 0 && seconds <60) { gotoXY (56,17); cout <<"Time taken: "; gotoXY (56,18); cout << seconds <<" seconds"<< endl; gotoXY (0,24); } else if (minutes > 0 && minutes <= 1) { gotoXY (54,15); cout <<"Time taken: "; gotoXY (54,16); cout << minutes << " minute " << seconds <<" seconds"<< endl; gotoXY (0,24); } else if (minutes > 1) { gotoXY (54,15); cout <<"Time taken: "; gotoXY (54,16); cout << minutes << " minutes " << seconds <<" seconds"<< endl; gotoXY (0,24); } seconds = 0; minutes = 0; }
void setup() { // set up the encoder interrupt to detect falling edge on digital pin 2 attachInterrupt(0, encoder_interrupt, FALLING); Serial.begin(115200); Serial.write("<h>time\tspeed\tcurrent\tcurrent_sense\tvoltage\tvoltage_sense</h>\n"); Serial.write("<u>ms\trpm\tmA\tcounts\tvolts\tcts</u>\n"); pinMode(LED_PWM_PIN, OUTPUT); pinMode(VOLT_PIN, INPUT); pinMode(INTERRUPTER_PIN, INPUT); pinMode(LED_PIN, OUTPUT); pinMode(BTN_PIN, INPUT); LcdInitialize(); gotoXY(0,0); LcdClear(); LcdString((char*)"Current:"); gotoXY(0,2); LcdString((char*)"Speed:"); gotoXY(0,4); LcdString((char*)"Voltage:"); blink_clock = millis(); tach_enc.min_hertz = 5; tach_enc.max_period = 5000; tach_enc.pin_num = INTERRUPTER_PIN; tach_enc.debounce_min = 5; tach_enc.alpha = 800; tach_enc.cts_per_rev = 1; tach_enc.hertz = 0; button.button_pin = BTN_PIN; button.button_state = btnDown; // pulser.carrier_clock = 0; // pulser.carrier_period = 5000; // pulser.step_clock = 0; // pulser.pulse_up_period = 1000; // pulser.pulse_down_period = 3500; // pulser.step_period_up = pulser.pulse_up_period / impulse_num_samples; // pulser.step_period_down = pulser.pulse_down_period / impulse_num_samples; // pulser.index = 0; // pulser.offset_time = 0; // start pulse at beginning of each carrier period volt_sensor.max_volts = 68000; // mV at sensor saturation (depends on pot adj) // init_impulse(impulse_array, impulse_num_samples, 255); }
/* * Name : update * Description : Write the screen buffer to the display memory * Argument(s) : none * Return value : none */ void Nokia_3310_lcd::update(void) { #ifdef USE_GRAPHIC int i,j; for(i=0; i< LCDROWMAX; i++) { gotoXY (0,i); for(j=0; j< LCDCOLMAX; j++) { writeData(lcd_buffer[i][j]); } } #endif gotoXY (0,0); //bring the XY position back to (0,0) }
void updatePixel(int col, int row, unsigned char fill) { int hPos = row/8; int pos = row%8; gotoXY(col, hPos); if(fill == 1) //fill { if (pos == 0) LCDBuffer[col][hPos] = LCDBuffer[col][hPos] | 0x01; else if (pos == 1) LCDBuffer[col][hPos] = LCDBuffer[col][hPos] | 0x02; else if (pos == 2) LCDBuffer[col][hPos] = LCDBuffer[col][hPos] | 0x04; else if (pos == 3) LCDBuffer[col][hPos] = LCDBuffer[col][hPos] | 0x08; else if (pos == 4) LCDBuffer[col][hPos] = LCDBuffer[col][hPos] | 0x10; else if (pos == 5) LCDBuffer[col][hPos] = LCDBuffer[col][hPos] | 0x20; else if (pos == 6) LCDBuffer[col][hPos] = LCDBuffer[col][hPos] | 0x40; else if (pos == 7) LCDBuffer[col][hPos] = LCDBuffer[col][hPos] | 0x80; } else //erase { if (pos == 0) LCDBuffer[col][hPos] = LCDBuffer[col][hPos] & ~0x01; else if (pos == 1) LCDBuffer[col][hPos] = LCDBuffer[col][hPos] & ~0x02; else if (pos == 2) LCDBuffer[col][hPos] = LCDBuffer[col][hPos] & ~0x04; else if (pos == 3) LCDBuffer[col][hPos] = LCDBuffer[col][hPos] & ~0x08; else if (pos == 4) LCDBuffer[col][hPos] = LCDBuffer[col][hPos] & ~0x10; else if (pos == 5) LCDBuffer[col][hPos] = LCDBuffer[col][hPos] & ~0x20; else if (pos == 6) LCDBuffer[col][hPos] = LCDBuffer[col][hPos] & ~0x40; else if (pos == 7) LCDBuffer[col][hPos] = LCDBuffer[col][hPos] & ~0x80; } LcdWrite(LCDBuffer[col][row/8]); gotoXY(99, 99); //move cursor out of bound LcdWrite(0x00); }
void PlayNRounds(int n){ #ifdef _WIN32 system("cls"); #elif defined(__linux__) system("clear"); #endif int score; Game myGame; bool isGameOver; dir_e dir; gotoXY(5,0); std::cout<<"Previous"; gotoXY(35,0); std::cout<<"Current (Hint: "<<myGame.getHint()<<")"; myGame.printGrid(35,2); if(myGame.isGameOver(score)) myGame.reset(); GameAgent* ai = new MonteCarloTreeSearch(); Grid myGrid; for(int i = 0;i < n;i++){ isGameOver = false; while(!isGameOver){ //while((dir = getDirFromKeyboard()) == INVALID); gotoXY(5,10); //std::cout<<dirToStr(dir); myGame.printGrid(5,2); ai->reset(); myGame.getCurrentGrid(myGrid); dir = ai->getAction(myGrid, myGame.getHint()); myGame.insertDirection(dir); gotoXY(50,0); std::cout<<myGame.getHint(); isGameOver = myGame.isGameOver(score); myGame.printGrid(35,2); } myGame.printGrid(35,2); if(i < n - 1) myGame.reset(); gotoXY(0,15); printf(" Round: %d \n", i+1); printf(" Score: %d \n", score); } delete ai; }
void drawBoarder(void) { int x = 0, y = 0, k = 0; //게임 보드 그리기 for (x = 0, k = 0; x<X_LEN; x++, k++) { for (y = 0; y<Y_LEN; y++) { if (BOARD_ARR[y][x] == LINE) { gotoXY(k + x + X_LEFT_BOARDER, y + Y_TOP_BOARDER); printf("▣"); } } } gotoXY(7, 2); printf("HCI's TETRIS GAME"); //게임 화면에 점수 보드 창을 그리기 for (y = 0; y<SCORE_HEIGHT; y++) { gotoXY(SCORE_STARTX, SCORE_STARTY + y); for (x = 0; x < SCORE_WIDTH; x++) if (scoreBoard[y][x] == LINE) printf("♥"); else printf(" "); } //랭킹 표시 gotoXY(35, 3); printf("1등 : %d점", rank1); gotoXY(35, 4); printf("2등 : %d점", rank2); gotoXY(35, 5); printf("3등 : %d점", rank3); gotoXY(35, 6); printf("4등 : %d점", rank4); gotoXY(35, 7); printf("5등 : %d점", rank5); }
void chooseLevel(Player *joueur) { DEFAUT; clrScr(); setColour(JAUNE_VIF,NOIR); gotoXY(38,3); printf("%c %c%c %c %c %c%c %c %c %c",219,219,219,219,219,219,219,219,219,219); setColour(BLEU_VIF,NOIR); gotoXY(38,4); printf("%c %c%c %c %c %c%c %c %c %c%c%c",219,219,254,219,219,219,254,219,219,219,254,219); setColour(ROUGE_VIF,NOIR); gotoXY(38,5); printf("%c%c %c%c %c %c%c %c%c %c %c %c",219,219,219,219,219,219,219,219,219,219,219,219); gotoXY(5,10); setColour(MAGENTA_VIF,NOIR); puts("EASY (1)"); RabbitHead(16,5); gotoXY(5,20); setColour(BLEU_VIF,NOIR); puts("MEDIUM (2)"); GeekHead(16,15); gotoXY(5,30); setColour(ROUGE_VIF,NOIR); puts("HARD (3)"); RedDogHead(16,25); gotoXY(79,10); setColour(BLANC_VIF,NOIR); puts("APOCALYPTIC (4)"); MastersHead(58,11); gotoXY(39,22); printf("Which level ? : "); scanf("%d",&joueur->level); }
void printMenu() { int menuLine = MENU_START_Y; gotoXY(PROMPT_X,PROMPT_Y); setColor(CYAN); printf("Please Enter Command: "); saveCursor(); gotoXY(MENU_START_X, menuLine++); printf("(P)ing Sensor"); gotoXY(MENU_START_X, menuLine++); printf("(L)ight LED"); gotoXY(MENU_START_X, menuLine++); printf("(T)oggle ADC"); gotoXY(MENU_START_X, menuLine++); printf("(R)eset ADC"); gotoXY(MENU_START_X, menuLine++); printf("(G)et Voltage"); gotoXY(MENU_START_X, menuLine++); printf("(D)isplay Graph"); gotoXY(MENU_START_X, menuLine++); printf("(Q)uit"); recallCursor(); }
// print() // Description: prints grid at given origin (xPos, yPos) // Arguments: // xPos - x coordinate of origin // yPos - y coordinate of origin void Grid::print(int xPos, int yPos){ #ifdef EN_PRINT for(int i = 0;i < GRID_LENGTH;i++){ for(int j = 0;j < GRID_LENGTH;j++){ int x = xPos + 6 * j; int y = yPos + 2 * i; gotoXY(x,y); std::cout<<" "; gotoXY(x,y); std::cout<<m_data[i*GRID_LENGTH + j]; } } #endif }
void main(void) { /* Initialize I/O and Peripherals for application */ InitApp(); //at end of user.c led_counter=0; spk_bit=0; //what are the spk_bits ??? led_bit=0; LCDInit(); LCDClear(); gotoXY(1,11); //(1,11) is about halfway down LCDString("PIC 16LF1786"); while(1) { /* TODO <INSERT USER APPLICATION CODE HERE> */ if(spk_bit==1) { if((spk_enable==1)&&(spk_enable2==1)) LATBbits.LATB6=1; //B6 is the clk in for uploading program to PIC }else LATBbits.LATB6=0; } }
//Clears the LCD by writing zeros to the entire screen void LCDClear(void) { for (u16 index = 0 ; index < (LCD_X * LCD_Y / 8) ; index++) LCDWrite(LCD_DATA, 0x00); gotoXY(0, 0); //After we clear the display, return to the home position }
int main(void){ Uart *uart = uart_init(); console_init(); _delay_ms(100); cli(); Spi *spi = spi_init(); sei(); printf("running.\n"); printf("Entering cmd mode\n"); LCD *lcd = lcd_new(SDA,SCL,0); thermistor_init(); char temps[64] = {0}; int l = 0; while(1){ gotoXY(lcd,0,0); l = sprintf(temps,"temp: %0.2fC°",thermistor_get_c()); temps[l-1] = 0; write_string(lcd,temps); printf("ping\n"); _delay_ms(100); } return 1; }
/* * Name : clear * Description : Clear the screen and display buffer * Argument(s) : none * Return value : none */ void Nokia_3310_lcd::clear(void) { int i,j; gotoXY (0,0); //start with (0,0) home position for(i=0; i< LCDROWMAX; i++) { for(j=0; j< LCDCOLMAX; j++) { writeData( 0x00 ); #ifdef USE_GRAPHIC lcd_buffer[i][j] = 0x00; #endif } } gotoXY (0,0); //bring the XY position back to (0,0) }
//function to read from text file void draw_object(string sFile, WORD wColor, int ixStart, int iyStart) { string buffer; int i = 0; ifstream ifile; ifile.open (sFile); colour(wColor); while (!ifile.eof()) { getline(ifile, buffer); gotoXY(ixStart, iyStart+i); cout << buffer << endl; i++; } ifile.close(); }
int main(void){ Uart *uart = uart_init(); console_init(); _delay_ms(100); cli(); Spi *spi = spi_init(); sei(); printf("running.\n"); printf("Entering cmd mode\n"); LCD *lcd = lcd_new(EXP1,EXP2,0); gotoXY(lcd,0,0); write_string(lcd,"-= deltabot =-\n"); write_string(lcd,"uart [OK]\n"); write_string(lcd,"spi [OK]\n"); write_string(lcd,"lcd [OK]\n"); thermistor_init(); write_string(lcd,"temp res [OK]\n"); while(1){ write_stringf(lcd,"temp: %0.2f%cC\r",thermistor_get_c(),(unsigned)0x7f); printf("ping\n"); _delay_ms(50); } return 1; }
dir_e computeDir(Grid &myGrid, char NT) { int m=0,ms=myGrid.getScore(),nt; float dm[4]={0}; dir_e bd=LEFT; for(int d=0;d<4;d++) { for(int i=0;i<RUNCNT;i++) { Grid tg=myGrid; if(!tg.shift(getDirFromInt(d))) break; //printf("%d\n", tg.getSlotNo());fflush(stdout); if(NT=='+') setNT(tg, genSNT(tg)); else { setNT(tg, NT-'0'); } for(int j=0;j<RUNDEP;j++) { if(!tg.shift(getRandDir())) continue; setNT(tg, getNT(tg)); } int s=tg.getScore(); if(s>m) { m=s; bd=getDirFromInt(d); } dm[d]+=s; } } int d=rand()%4; float dmm=dm[d]; gotoXY(5,20); for(int i=0;i<4;i++) { if(dm[i]>dmm) { dmm=dm[i]; d=i; } //printf("%.0f ", dm[i]); } //printf("\n%.0f %d\n", dmm, m); //printf("%d %d\n", d, bd); if(dmm/RUNCNT*DTHRS>m) return getDirFromInt(d); return bd; }
void loop() { gotoXY(0, 5); LCDString("Please wait."); LCDClear(); gotoXY(0, 0); LCDString("{BTC PRICES}"); gotoXY(0, 2); LCDString("$= "); gotoXY(0, 5); LCDString("Updated! "); delay(1000); gotoXY(0, 5); LCDString(" "); gotoXY(0, 5); for (int x=0; x <= 11; x++){ LCDString("."); delay(1000); } gotoXY(0, 5); for (int x=0; x <= 11; x++){ LCDString(" "); delay(1000); } }
//빈 사각형을 대입한 값에 따라 만든다. void printSquare(int startX, int startY, int width, int height, char ch) { int i; for(i = 0; i <= width; i++){// 두개의 세로선 긋기 gotoXY(startX + i, startY); putchar(ch); gotoXY(startX + i, startY + height); putchar(ch); } for(i = 0; i <= height; i++){// 두개의 가로선 긋기 gotoXY(startX, startY + i); putchar(ch); gotoXY(startX + width, startY + i); putchar(ch); } }
void snake::moveStep() { if(createFood_lock == true) { cout<<"creating food"<<endl; return; } switch(direct) { case UP: if(MAP[head.x-1][head.y]==NOTHING) { gotoXY(head.x-1,head.y); } else if(MAP[head.x-1][head.y]==FOOD) getFood(); else gameOver=true; break; case DOWN: if(MAP[head.x+1][head.y]==NOTHING) { gotoXY(head.x+1,head.y); } else if(MAP[head.x+1][head.y]==FOOD) getFood(); else gameOver=true; break; case LEFT: if(MAP[head.x][head.y-1]==NOTHING) { gotoXY(head.x,head.y-1); } else if(MAP[head.x][head.y-1]==FOOD) getFood(); else gameOver=true; break; case RIGHT: if(MAP[head.x][head.y+1]==NOTHING) { gotoXY(head.x,head.y+1); } else if(MAP[head.x][head.y+1]==FOOD) getFood(); else gameOver=true; break; default:break; } }
void init_graphics2() { memset((void *)(0x90000000), 0, my_lcd_config.virtual_xres * my_lcd_config.virtual_yres * my_lcd_config.pixelsize / 8); lcd_on(); init_gdi_driver(&my_lcd_config); SetLCD_Conf(&my_lcd_config); InitDriver(); setDevice(1); //change gotoXY(0,0); };
float getVoltage(int dataPath[]) { int i; int adcValue = 0; float voltage = 0; message msgOut; message msgIn; msgOut.data = 0x2; sendMessage(msgOut, dataPath); for (i = 2; i >= 0; i--) { msgIn = receiveMessage(dataPath); adcValue |= (msgIn.data << (i * DATA_PATH_SIZE)); } msgIn = receiveMessage(dataPath); if (msgIn.data == 0xE) { adcValue &= 0x3FF; voltage = (float) ((adcValue/1024.0) * 5.0); } else { gotoXY(STATUS_X,STATUS_Y); clearLine(STATUS_Y); setColor(RESET); printf("[\033[0;31m Error \033[m]\t Message Acknowledgment Failed \033[u"); return (-1); } gotoXY((GRAPH_END_X - 20),(GRAPH_END_Y + 2) ); printf("Voltage: %f", voltage); return (voltage); }
void setDisplay(){ if (modechanged){ gotoXY(0,0); sprintf(cha, " Ustaw. wysw.");LcdString(cha, true); gotoXY(0,1); sprintf(cha, EMPTY_LINE);LcdString(cha, false); } gotoXY(0,1); sprintf(cha, "kontrast:");LcdString(cha,false); gotoXY(60,1); sprintf(cha, "%02i", contrast_val);LcdString(cha, (pos_setDisp==0)); gotoXY(0,2); sprintf(cha, "jasnosc:");LcdString(cha,false); gotoXY(60,2); sprintf(cha, "%02i", jasnosc_val);LcdString(cha, (pos_setDisp==1)); gotoXY(0,3); sprintf(cha, "OK");LcdString(cha,(pos_setDisp==2)); if (modechanged){ gotoXY(0,4); sprintf(cha, "<> poprz/nast");LcdString(cha); gotoXY(0,5); sprintf(cha, "^v wart +/-");LcdString(cha); modechanged=false; } if (pos_setDisp==0){ if (isUp()) { contrast_val=obetnij(contrast_val+1, 10, true); LcdInitialise(); } if (isDown()) { contrast_val=obetnij(contrast_val-1, 10, true); LcdInitialise(); } } else if (pos_setDisp==1){ if (isUp()) { jasnosc_val=obetnij(jasnosc_val+1, 50); analogWrite(11, jasnosc_val); } if (isDown()) { jasnosc_val=obetnij(jasnosc_val-1, 50); analogWrite(11, jasnosc_val); } } if (pos_setDisp==2){ if (isPressed()) { mode=1; modechanged=true; LcdClear(); return; } } if (isRight()) pos_setDisp++; if (isLeft()) pos_setDisp--; if (pos_setDisp>2) pos_setDisp=0; if (pos_setDisp<0) pos_setDisp=2; }
void PlayNRounds(int n){ #ifdef _WIN32 system("cls"); #elif defined(__linux__) system("clear"); #endif int score; Game myGame; bool isGameOver; dir_e dir; gotoXY(5,0); std::cout<<"Previous"; gotoXY(35,0); std::cout<<"Current (Hint: "<<myGame.getHint()<<")"; myGame.printGrid(35,2); if(myGame.isGameOver(score)) myGame.reset(); Grid myGrid; for(int i = 0;i < n;i++){ isGameOver = false; while(!isGameOver){ dir = getRandDir(); gotoXY(5,10); std::cout<<dirToStr(dir); myGame.printGrid(5,2); myGame.insertDirection(dir); gotoXY(50,0); std::cout<<myGame.getHint(); isGameOver = myGame.isGameOver(score); myGame.printGrid(35,2); } myGame.printGrid(35,2); if(i < n - 1) myGame.reset(); gotoXY(0,15); printf(" Round: %d \n", i+1); printf(" Score: %d \n", score); } }
void LcdCharacterBig (int x, int y,char character, bool negate){ int c = character-48+3; if (character=='.') c=1; if (character=='-') c=0; for (int index = 0; index < 42; index++) { gotoXY(x+(index%14), y+index/14); byte b=pgm_read_byte(&(BigNumber[c][index])); if (negate) b=~b; LcdWrite(LCD_D, b); } }