static gboolean check_ac_adapter( batt* b ) { FILE *state; char buf[ 256 ]; char* pstr; if (!(state = fopen( AC_ADAPTER_STATE_FILE, "r"))) { if ((state = fopen( AC_ADAPTER_STATE_SYSFS_FILE, "r"))) { b->use_sysfs = TRUE; } else { return FALSE; } } gboolean has_ac_adapter = FALSE; if (b->use_sysfs) { while( fgets(buf, 256, state) && ! sscanf(buf, "%d", &has_ac_adapter) ); } else { while( fgets(buf, 256, state) && ! ( pstr = strstr(buf, "state:") ) ); if( pstr ) { pstr += 6; while( *pstr && *pstr == ' ' ) ++pstr; if( pstr[0] == 'o' && pstr[1] == 'n' ) has_ac_adapter = TRUE; } } fclose(state); /* if the state of AC adapter changed, is_charging of the batteries might change, too. */ if( has_ac_adapter != b->has_ac_adapter ) { /* g_debug( "ac_state_changed: %d", has_ac_adapter ); */ b->has_ac_adapter = has_ac_adapter; /* update the state of all batteries */ g_list_foreach( b->batteries, (GFunc)get_batt_state, &b->use_sysfs ); update_display( b, TRUE ); } return TRUE; }
void esq2x40_sq1_t::write_char(int data) { if (m_Wait87Shift) { // printf("87Shift got %02x\n", data); if (data == 0x00) // clear { m_cursx = m_cursy = 0; memset(m_chars, 0, sizeof(m_chars)); memset(m_attrs, 0, sizeof(m_attrs)); memset(m_dirty, 1, sizeof(m_dirty)); } m_Wait87Shift = false; } else if ((data >= 0x20) && (data <= 0x7f)) { m_chars[m_cursy][m_cursx] = data - ' '; m_attrs[m_cursy][m_cursx] = m_curattr; m_dirty[m_cursy][m_cursx] = 1; m_cursx++; if (m_cursx >= 39) { m_cursx = 39; } update_display(); } else if (data == 0x83) { m_cursx = m_cursy = 0; memset(m_chars, 0, sizeof(m_chars)); memset(m_attrs, 0, sizeof(m_attrs)); memset(m_dirty, 1, sizeof(m_dirty)); } else if (data == 0x87) { m_Wait87Shift = true; } else { // printf("SQ-1 unhandled display char %02x\n", data); } }
int main_chmon(int argc, char* argv[]) { if (argc!=2) { printf("Usage: chmon <port>\n"); _exit(-1); } const char* devicename = argv[1]; printf("Waiting for port to become available\n"); while (access(devicename, F_OK)!=0) { sleep(1); } int fd = -1; printf("Waiting for access to port\n"); while (1) { fd = open(devicename, O_RDWR | O_NOCTTY | O_NONBLOCK); if (fd>=0) break; perror("Waiting for port:"); } arduino_speed(fd); // enter the main loop while (1) { // check for messages in the message file check_messages(fd); // get temperature and write it to file. get_temperature(fd); // read in the thermostat temperature get_thermostat(); // update relay update_relay(fd); // update display update_display(fd); } return 0; }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Diagonal"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorBlack); resource_init_current_app(&APP_RESOURCES); bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image); layer_add_child(&window.layer, &background_image.layer.layer); // Avoids a blank screen on watch start. PblTm tick_time; get_time(&tick_time); update_display(&tick_time); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Complexity"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorBlack); resource_init_current_app(&APP_RESOURCES); text_layer_init(&text_date_layer, window.layer.frame); text_layer_set_text_color(&text_date_layer, GColorWhite); text_layer_set_background_color(&text_date_layer, GColorClear); layer_set_frame(&text_date_layer.layer, GRect(8, 44, 144-8, 168-44)); text_layer_set_font(&text_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21))); layer_add_child(&window.layer, &text_date_layer.layer); text_layer_init(&text_day_layer, window.layer.frame); text_layer_set_text_color(&text_day_layer, GColorWhite); text_layer_set_background_color(&text_day_layer, GColorClear); layer_set_frame(&text_day_layer.layer, GRect(8, 68, 144-8, 168-68)); text_layer_set_font(&text_day_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21))); layer_add_child(&window.layer, &text_day_layer.layer); text_layer_init(&text_time_layer, window.layer.frame); text_layer_set_text_color(&text_time_layer, GColorWhite); text_layer_set_background_color(&text_time_layer, GColorClear); layer_set_frame(&text_time_layer.layer, GRect(7, 92, 144-7, 168-92)); text_layer_set_font(&text_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_49))); layer_add_child(&window.layer, &text_time_layer.layer); layer_init(&line_layer, window.layer.frame); line_layer.update_proc = &line_layer_update_callback; layer_add_child(&window.layer, &line_layer); // Avoid blank display on launch PblTm tick_time; get_time(&tick_time); update_display(&tick_time); }
int main(void) { /* Declare variables for projectile modelling */ double pos_x, pos_y, init_pos_x, init_pos_y, vel_x, vel_y; double time, gravity; /* Initialise the projectile position */ init_pos_x = 100; init_pos_y = 340; /* Initialise the projectile velocity */ vel_x = 60; vel_y = 60; /* Initialise gravity */ gravity = 9.81; /* Open a graphics window */ /* Make it 640 pixels wide by 480 pixels high */ initwindow(640, 480); /* Move to starting position */ moveto((int)init_pos_x, (int)init_pos_y); /* Loop over time */ for (pos_x = init_pos_x; pos_y <= init_pos_y; pos_x++) { /* Calculate new height */ time = (pos_x - init_pos_x) / vel_x; pos_y = init_pos_y - (vel_y * time) + (gravity * time * time); /* Draw a line */ lineto((int)pos_x, (int)pos_y, 1); update_display(); } /* Wait for a key press */ getch(); /* Close the graphics window */ closegraph(); return 0; }
static void main_window_load (Window *window) { Layer *window_layer = window_get_root_layer(window); // Set the lyrics layer setting... platformSettings.grect_lyrics_layer = PBL_IF_RECT_ELSE(GRect(0,0,144,65),layer_get_bounds(window_layer)); s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_TOP_LOGO); s_background_bitmap_dithered = gbitmap_create_with_resource(RESOURCE_ID_TOP_LOGO_DITHER); s_background_bitmap_thin = gbitmap_create_with_resource(RESOURCE_ID_THIN_TOP_LOGO); s_background_layer = bitmap_layer_create(platformSettings.grect_background_layer); layer_add_child(window_layer, bitmap_layer_get_layer(s_background_layer)); s_time_layer = text_layer_create(platformSettings.grect_time_layer); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_font(s_time_layer,fonts_get_system_font(FONT_KEY_BITHAM_34_MEDIUM_NUMBERS)); layer_add_child(window_layer,text_layer_get_layer(s_time_layer)); s_date_layer = text_layer_create(platformSettings.grect_date_layer); text_layer_set_text_alignment(s_date_layer, PBL_IF_RECT_ELSE(GTextAlignmentRight,GTextAlignmentLeft)); text_layer_set_background_color(s_date_layer, GColorClear); text_layer_set_font(s_date_layer,fonts_get_system_font(FONT_KEY_GOTHIC_18)); layer_add_child(window_layer,text_layer_get_layer(s_date_layer)); s_dayOfWeek_layer = text_layer_create(platformSettings.grect_dayOfWeek_layer); text_layer_set_text_alignment(s_dayOfWeek_layer, PBL_IF_RECT_ELSE(GTextAlignmentRight,GTextAlignmentLeft)); text_layer_set_background_color(s_dayOfWeek_layer, GColorClear); text_layer_set_font(s_dayOfWeek_layer,fonts_get_system_font(FONT_KEY_GOTHIC_18)); layer_add_child(window_layer,text_layer_get_layer(s_dayOfWeek_layer)); s_lyrics_layer = text_layer_create(platformSettings.grect_lyrics_layer); text_layer_set_font(s_lyrics_layer,fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_background_color(s_lyrics_layer, GColorClear); text_layer_set_text_alignment(s_lyrics_layer, GTextAlignmentCenter); layer_add_child(window_layer,text_layer_get_layer(s_lyrics_layer)); text_layer_enable_screen_text_flow_and_paging(s_lyrics_layer, 1); // Load time when window is loaded time_t now = time(NULL); tick_handler(localtime(&now),MINUTE_UNIT | DAY_UNIT); update_display(); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Beer O Clock"); window_stack_push(&window, true); window_set_background_color(&window, GColorBlack); resource_init_current_app(&APP_RESOURCES); // Mug bmp_init_container(RESOURCE_ID_IMAGE_MUG, &imageMug); imageMug.layer.layer.frame.origin.x = 25; imageMug.layer.layer.frame.origin.y = 11; layer_add_child(&window.layer, &imageMug.layer.layer); // Beer and its container layer_init(&beerContainer, GRect(25, 0, 66, 125)); bmp_init_container(RESOURCE_ID_IMAGE_BEER, &imageBeer); bitmap_layer_set_compositing_mode(&imageBeer.layer, GCompOpOr); imageBeer.layer.layer.frame.origin.x = 0; imageBeer.layer.layer.frame.origin.y = BEER_STARTING_Y; layer_add_child(&window.layer, &beerContainer); layer_add_child(&beerContainer, &imageBeer.layer.layer); // BOC rotbmp_pair_init_container(RESOURCE_ID_IMAGE_TEXT_WHITE, RESOURCE_ID_IMAGE_TEXT_BLACK, &imageBOC); imageBOC.layer.layer.frame.origin.x = 3; imageBOC.layer.layer.frame.origin.y = 65; layer_add_child(&window.layer, &imageBOC.layer.layer); // Time display text_layer_init(&timeLayer, GRect(40, 140, 80, 40)); text_layer_set_text_color(&timeLayer, GColorWhite); text_layer_set_background_color(&timeLayer, GColorClear); text_layer_set_font(&timeLayer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); layer_add_child(&window.layer, &timeLayer.layer); // Avoid a blank screen on watch start PblTm tick_time; get_time(&tick_time); update_display(&tick_time); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Rorschach"); window_stack_push(&window, false /* Animated */); window_set_background_color(&window, GColorWhite); resource_init_current_app(&APP_RESOURCES); layer_mark_dirty(&layer); // Avoids a blank screen on watch start. PblTm tick_time; get_time(&tick_time); update_display(&tick_time); }
static void main_window_load(Window *window) { // Get information about the Window Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); // CANVAS s_canvas_layer = layer_create(bounds); layer_set_update_proc(s_canvas_layer ,canvas_update_proc); layer_add_child(window_layer, s_canvas_layer); // TIME s_time_layer = text_layer_create( GRect(0, PBL_IF_ROUND_ELSE(58, 52), bounds.size.w, 50)); text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_text_color(s_time_layer, GColorBlack); text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(s_time_layer)); // DATE s_date_layer = text_layer_create(GRect(0, 105, bounds.size.w, 30)); text_layer_set_background_color(s_date_layer, GColorClear); text_layer_set_text_color(s_date_layer, GColorWhite); text_layer_set_font(s_date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(s_date_layer)); // STEPS s_steps_layer = text_layer_create(GRect(0, 40, bounds.size.w, 30)); text_layer_set_background_color(s_steps_layer, GColorClear); text_layer_set_text_color(s_steps_layer, GColorBlack); text_layer_set_font(s_steps_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); text_layer_set_text_alignment(s_steps_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(s_steps_layer)); update_display(); }
void handle_init( AppContextRef ctx ) { (void) ctx; window_init( &window, MY_WATCHNAME ); window_stack_push( &window, true ); window_set_background_color( &window, GColorBlack ); resource_init_current_app( &APP_RESOURCES ); // background bmp_init_container( RESOURCE_ID_IMAGE_BACKGROUND, &background_image ); layer_add_child( &window.layer, &background_image.layer.layer ); // day and date text text_layer_init( &text_date_layer, GRect( 0, 30, PEBBLE_WIDTH, 31 ) ); text_layer_set_text_color( &text_date_layer, GColorBlack ); text_layer_set_background_color( &text_date_layer, GColorClear ); text_layer_set_font( &text_date_layer, fonts_load_custom_font( resource_get_handle( RESOURCE_ID_FONT_LIBERATION_SANS_BOLD_14 ) ) ); text_layer_set_text_alignment( &text_date_layer, GTextAlignmentCenter ); layer_add_child( &window.layer, &text_date_layer.layer ); // main time display text_layer_init( &text_time_layer, GRect( 0, 56, PEBBLE_WIDTH, 50 ) ); text_layer_set_text_color( &text_time_layer, GColorBlack ); text_layer_set_background_color( &text_time_layer, GColorClear ); text_layer_set_font( &text_time_layer, fonts_load_custom_font( resource_get_handle( RESOURCE_ID_FONT_LIBERATION_SANS_BOLD_48 ) ) ); text_layer_set_text_alignment( &text_time_layer, GTextAlignmentCenter ); layer_add_child( &window.layer, &text_time_layer.layer ); // year-month-day, ISO week number, and ordinal date text_layer_init( &text_iso_layer, GRect( 0, 110, PEBBLE_WIDTH, 45 ) ); text_layer_set_text_color( &text_iso_layer, GColorBlack ); text_layer_set_background_color( &text_iso_layer, GColorClear ); text_layer_set_font( &text_iso_layer, fonts_load_custom_font( resource_get_handle( RESOURCE_ID_FONT_LIBERATION_MONO_14 ) ) ); text_layer_set_text_alignment( &text_iso_layer, GTextAlignmentCenter ); layer_add_child( &window.layer, &text_iso_layer.layer ); // update once at startup PblTm tick_time; get_time( &tick_time ); update_display( &tick_time ); }
bool target_graphics_buffer_update(void) { bool rate_changed = false; if (currprefs.gfx_monitor.gfx_size.height != changed_prefs.gfx_monitor.gfx_size.height) { update_display(&changed_prefs); rate_changed = true; } if (rate_changed) { black_screen_now(); fpscounter_reset(); time_per_frame = time_for_host_hz_frames / (currprefs.chipset_refreshrate); } reset_sync(); return true; }
void LayerSetup(PblTm *tick_time) { //21pt GFont custom_font21 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_DIGITAL21)); //Init the parent layer at (0,0) and size (144 X 168) layer_init(&parent, GRect(0, 0, 144, 168)); text_layer_init(&text_layer_4, GRect(46, 105, 60, 30)); // Month text_layer_init(&text_layer_5, GRect(114, 105, 30, 30)); // Date text_layer_init(&text_layer_6, GRect(114, 48, 30, 30)); // AM/PM text_layer_set_font(&text_layer_4, custom_font21); text_layer_set_font(&text_layer_5, custom_font21); text_layer_set_font(&text_layer_6, custom_font21); text_layer_set_background_color(&text_layer_4, GColorBlack); text_layer_set_background_color(&text_layer_5, GColorBlack); text_layer_set_background_color(&text_layer_6, GColorBlack); text_layer_set_text_color(&text_layer_4, GColorWhite); text_layer_set_text_color(&text_layer_5, GColorWhite); text_layer_set_text_color(&text_layer_6, GColorWhite); text_layer_set_text_alignment(&text_layer_4, GTextAlignmentRight); text_layer_set_text_alignment(&text_layer_5, GTextAlignmentLeft); text_layer_set_text_alignment(&text_layer_6, GTextAlignmentRight); layer_add_child(&parent, &text_layer_5.layer); layer_add_child(&parent, &text_layer_4.layer); layer_add_child(&parent, &text_layer_6.layer); layer_add_child(&window.layer, &parent); bmp_init_container(RESOURCE_ID_IMAGE_COLON, &cursor_layer); cursor_layer.layer.layer.frame.origin.x = 64; cursor_layer.layer.layer.frame.origin.y = 54; layer_add_child(&parent, &cursor_layer.layer.layer); update_display(tick_time); }
void Daten::testdaten( int min, int max, int abw, int namen, int farben, int werte) { int i, k, len; int unten, oben; char nambuf[NAMLEN+1]; assert( min <= max); srand( (unsigned)time( NULL )); if( abw < 0) abw = max - min; for( i = 0; i < anz_z; i++) { if( namen) { len = zufall( 3, NAMLEN); for( k = 0; k < len; k++) nambuf[k] = zufall( 'a', 'z'); nambuf[0] = toupper( nambuf[0]); nambuf[len] = 0; reihenname[i] = nambuf; } if( farben) farbe[i] = RGB( rand()%256, rand()%256, rand()%256); if( werte) { wert[i][0] = zufall( min, max); for( k = 1; k < anz_s; k++) { unten = wert[i][k-1] - abw; if( unten < min) unten = min; oben = wert[i][k-1] + abw; if( oben > max) oben = max; wert[i][k] = zufall( unten, oben); } } } update_display(); }
bool target_graphics_buffer_update (void) { bool rate_changed = SetVSyncRate(currprefs.chipset_refreshrate); if(currprefs.gfx_size.height != changed_prefs.gfx_size.height) { update_display(&changed_prefs); rate_changed = true; } if(rate_changed) { black_screen_now(); fpscounter_reset(); time_per_frame = 1000 * 1000 / (currprefs.chipset_refreshrate); } return true; }
AddAuto::AddAuto(TTCP *ttcp, QWidget *parent) : QMainWindow(parent) { setupUi(this); this->ttcp = ttcp; // TTCP is need to update the autoselect data AutoModel *model = new AutoModel(this); view->setModel(model); connect(ttcp, SIGNAL( add_autoentry(QString, int, int, QString, QString, QString, QString, QString, QString, QString, QString)), model, SLOT( add_autoentry(QString, int, int, QString, QString, QString, QString, QString, QString, QString, QString) ) ); connect(view, SIGNAL(entered(QModelIndex)), this, SLOT(update_display(QModelIndex))); connect(Grab, SIGNAL(clicked()), this, SLOT(grabClicked())); connect(buttonOk, SIGNAL(clicked()), this, SLOT(setAuto())); }
int main() { uint8_t *httpchar = 0; MAP_WDT_A_holdTimer(); UART_PC_init(); init_timer32_0(); SL_D_init(); UART_GSM_init(); while(1){ if(call_server_flag){ httpchar = request_to_server(); update_display(httpchar); call_server_flag = false; //reset flag init_timer32_0(); } } }
int server_cycle(event_t event) { int res; if (current_cycles >= max_cycles || event == EVENT_FINISH) { ndprintf(stdout, "[GAME] Ended - Draw!\n"); res = 1; } else { current_cycles++; charge_timer(); cycle(); update_display(); res = process_robots(1); } if (res) { gettimeofday(&game_end, NULL); complete_ranking(); } return res; }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Trekkie"); window_stack_push(&window, true /* Animated */); resource_init_current_app(&APP_RESOURCES); bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image); layer_add_child(&window.layer, &background_image.layer.layer); // Date Layer text_layer_init(&text_date_layer, window.layer.frame); text_layer_set_text_color(&text_date_layer, GColorWhite); text_layer_set_background_color(&text_date_layer, GColorClear); layer_set_frame(&text_date_layer.layer, GRect(78, 5, 144-78, 168-5)); text_layer_set_font(&text_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LCARS_BOLD_17))); layer_add_child(&window.layer, &text_date_layer.layer); // Time Layer text_layer_init(&text_time_layer, window.layer.frame); text_layer_set_text_color(&text_time_layer, GColorWhite); text_layer_set_background_color(&text_time_layer, GColorClear); layer_set_frame(&text_time_layer.layer, GRect(40, 48, 144-40, 168-48)); text_layer_set_font(&text_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LCARS_60))); layer_add_child(&window.layer, &text_time_layer.layer); // AMPM Layer text_layer_init(&text_ampm_layer, window.layer.frame); text_layer_set_text_color(&text_ampm_layer, GColorWhite); text_layer_set_background_color(&text_ampm_layer, GColorClear); layer_set_frame(&text_ampm_layer.layer, GRect(40, 105, 144-40, 168-105)); text_layer_set_font(&text_ampm_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LCARS_BOLD_17))); layer_add_child(&window.layer, &text_ampm_layer.layer); // No blank screen on init. PblTm tick_time; get_time(&tick_time); update_display(&tick_time); }
//state machine of therm type //phase 0 : search the current channel and switch to it if apply, add delay, to phase 1, otherwise to phase 2 //phase 1:get the reading and update the display //phase 2: move to next channel uchar therm_state() { uchar i; if(phase > 2) phase = 0; if(phase == 0) { update_led(1); if( (sysdata.type_therm >= PRBTYPE_K) && (sysdata.type_therm <= PRBTYPE_R)) { scanner_set_channel(ch_to_search+1); dlg_cnt = 6*ONESEC; onesec_cnt = 0; phase = 1; return 0; }else{ rundata.temperature[ch_to_search] = -9999; //invalid data phase = 2; } } if(phase == 1) { rundata.reading[ch_to_search] = pickfrom5();//nav_read();//-sysdata.V0; //sprintf(strbuf,"%2d;%f;",ch_to_search+1,rundata.reading[ch_to_search]); //no work //prints(strbuf,strlen(strbuf),PORT_PC); rundata.temperature[ch_to_search] = MValueToTValue(rundata.reading[ch_to_search], sysdata.type_therm); //sprintf(strbuf,"%f;\r\n",rundata.temperature[ch_to_search]); //prints(strbuf,strlen(strbuf),PORT_PC); phase = 2; } if(phase == 2) { update_display(); phase = 0; } return 1; //one reading is updated }
void bfm_bd1_t::shift_clock(int state) { if (m_sclk != state) { if (!m_sclk) { m_shift_data <<= 1; if ( !m_data ) m_shift_data |= 1; if ( ++m_shift_count >= 8 ) { write_char(m_shift_data); m_shift_count = 0; m_shift_data = 0; } update_display(); } } m_sclk = state; }
static void net_cb (EV_P_ ev_io *w, int revents) { if(http_response_process(NULL)) { net_io=0; if((resp_ret.type==REQ_SUBMIT)&&(!resp_ret.result)) { http_request(REQ_QUERY); net_io=1; status=WAIT; } else { status=READY; update_display("default.png",0); } write_to_usb(resp_ret.type,resp_ret.type); } ghttp_flush_response_buffer(request); ev_break (EV_A_ EVBREAK_ALL); }
void Daten::init( int z, int s, const CString& n) { int i, k; char buf[12]; assert( z <= MAX_ZEILEN); assert( s <= MAX_SPALTEN); anz_z = z; anz_s = s; name = n; for( i = 0; i < z; i++) { sprintf( buf, "Reihe %d", i+1); reihenname[i] = buf; farbe[i] = RGB( 0, 0, 0); for( k = 0; k < s; k++) wert[i][k] = 0; } update_display(); }
void rocvfd_t::shift_clock(int state) { if (m_sclk != state) { //Clock data on FALLING edge if (!m_sclk) { m_shift_data <<= 1; if ( m_data ) m_shift_data |= 1; if ( ++m_shift_count >= 8 ) { write_char(m_shift_data); m_shift_count = 0; m_shift_data = 0; } update_display(); } } m_sclk = state; }
int check_prefs_changed_gfx (void) { int changed = 0; if(currprefs.gfx_size.height != changed_prefs.gfx_size.height || currprefs.gfx_size.width != changed_prefs.gfx_size.width || currprefs.gfx_size_fs.width != changed_prefs.gfx_size_fs.width || currprefs.gfx_resolution != changed_prefs.gfx_resolution) { cfgfile_configuration_change(1); currprefs.gfx_size.height = changed_prefs.gfx_size.height; currprefs.gfx_size.width = changed_prefs.gfx_size.width; currprefs.gfx_size_fs.width = changed_prefs.gfx_size_fs.width; currprefs.gfx_resolution = changed_prefs.gfx_resolution; update_display(&currprefs); changed = 1; } if (currprefs.leds_on_screen != changed_prefs.leds_on_screen || currprefs.pandora_hide_idle_led != changed_prefs.pandora_hide_idle_led || currprefs.pandora_vertical_offset != changed_prefs.pandora_vertical_offset) { currprefs.leds_on_screen = changed_prefs.leds_on_screen; currprefs.pandora_hide_idle_led = changed_prefs.pandora_hide_idle_led; currprefs.pandora_vertical_offset = changed_prefs.pandora_vertical_offset; changed = 1; } if (currprefs.chipset_refreshrate != changed_prefs.chipset_refreshrate) { currprefs.chipset_refreshrate = changed_prefs.chipset_refreshrate; init_hz_full (); changed = 1; } currprefs.filesys_limit = changed_prefs.filesys_limit; return changed; }
static Bool phosphor_event (Display *dpy, Window window, void *closure, XEvent *event) { p_state *state = (p_state *) closure; if (event->xany.type == Expose) update_display (state, False); else if (event->xany.type == KeyPress) { KeySym keysym; unsigned char c = 0; XLookupString (&event->xkey, (char *) &c, 1, &keysym, &state->compose); if (c != 0 && state->pipe) { if (!state->swap_bs_del_p) ; else if (c == 127) c = 8; else if (c == 8) c = 127; /* If meta was held down, send ESC, or turn on the high bit. */ if (event->xkey.state & meta_modifier (state)) { if (state->meta_sends_esc_p) fputc ('\033', state->pipe); else c |= 0x80; } fputc (c, state->pipe); fflush (state->pipe); event->xany.type = 0; /* don't interpret this event defaultly. */ } return True; } return False; }
int main(int argc, char **argv) { init(); /* Query for a keypress until the user kills the program. */ while(!emergency_stop) { update_display(); } // Display the emergency exit message. clearLCD(); moveLCDCursor(LCD_LINE_1); LoadStrLCD("Emergency stop"); ATD0CTL2 = 0; // Turn off the ATD SETMSK(DDRK, 0x20); /* Enable output to the buzzer. */ SETMSK(PORTK, 0x20); /* Turn on the buzzer. */ delay(); /* Delay for ~1 second. */ CLRMSK(PORTK, 0x20); /* Turn off the buzzer. */ return 0; /* Satisfy the compiler. */ }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "BMO"); window_stack_push(&window, true /* Animated */); resource_init_current_app(&APP_RESOURCES); bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image); layer_add_child(&window.layer, &background_image.layer.layer); // Date Layer text_layer_init(&text_date_layer, window.layer.frame); text_layer_set_text_color(&text_date_layer, GColorBlack); text_layer_set_background_color(&text_date_layer, GColorClear); layer_set_frame(&text_date_layer.layer, GRect(0, 88, 144, 168-88)); text_layer_set_text_alignment(&text_date_layer, GTextAlignmentCenter); text_layer_set_font(&text_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_12))); layer_add_child(&window.layer, &text_date_layer.layer); // Time Layer GRect time_rect; text_layer_init(&text_time_layer, window.layer.frame); text_layer_set_text_color(&text_time_layer, GColorBlack); text_layer_set_background_color(&text_time_layer, GColorClear); layer_set_frame(&text_time_layer.layer, GRect(0, 54, 144, 168-54)); text_layer_set_text_alignment(&text_time_layer, GTextAlignmentCenter); text_layer_set_font(&text_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_29))); layer_add_child(&window.layer, &text_time_layer.layer); // No blank screen on init. PblTm tick_time; get_time(&tick_time); update_display(&tick_time); }
void handle_init(AppContextRef ctx) { window_init(&window, "91 Dub"); window_stack_push(&window, true /* Animated */); resource_init_current_app(&APP_RESOURCES); bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image); layer_add_child(&window.layer, &background_image.layer.layer); bmp_init_container(RESOURCE_ID_IMAGE_METER_BAR, &meter_bar_image); meter_bar_image.layer.layer.frame.origin.x = 17; meter_bar_image.layer.layer.frame.origin.y = 43; layer_add_child(&window.layer, &meter_bar_image.layer.layer); if (clock_is_24h_style()) { bmp_init_container(RESOURCE_ID_IMAGE_24_HOUR_MODE, &time_format_image); time_format_image.layer.layer.frame.origin.x = 17; time_format_image.layer.layer.frame.origin.y = 68; layer_add_child(&window.layer, &time_format_image.layer.layer); } // Avoids a blank screen on watch start. PblTm tick_time; get_time(&tick_time); update_display(&tick_time); }
static void on_insert_numbers_activate(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer gdata) { InsertNumbersDialog d; GtkWidget *vbox, *label, *upper, *space, *button; GtkGrid *grid; GtkComboBoxText *combo; const char *case_tip = _("For base 11 and above"); gchar *base_text; gint result; d.dialog = gtk_dialog_new_with_buttons(_("Insert Numbers"), GTK_WINDOW(geany->main_widgets->window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); vbox = ui_dialog_vbox_new(GTK_DIALOG(d.dialog)); gtk_box_set_spacing(GTK_BOX(vbox), 9); #if GTK_CHECK_VERSION(3, 0, 0) grid = GTK_GRID(gtk_grid_new()); #else grid = GTK_TABLE(gtk_table_new(3, 6, FALSE)); #endif gtk_grid_set_row_spacing(grid, 6); gtk_grid_set_column_spacing(grid, 6); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(grid), TRUE, TRUE, 0); label = gtk_label_new_with_mnemonic(_("_Start:")); gtk_grid_attach(grid, label, 0, 0, 1, 1); d.start = gtk_spin_button_new_with_range(RANGE_MIN, RANGE_MAX, 1); set_entry(d.start, RANGE_LEN, label, RANGE_TOOLTIP); gtk_grid_attach(grid, d.start, 1, 0, 2, 1); label = gtk_label_new_with_mnemonic(_("S_tep:")); gtk_grid_attach(grid, label, 3, 0, 1, 1); d.step = gtk_spin_button_new_with_range(RANGE_MIN, RANGE_MAX, 1); set_entry(d.step, RANGE_LEN, label, RANGE_TOOLTIP); gtk_grid_attach(grid, d.step, 4, 0, 2, 1); label = gtk_label_new_with_mnemonic(_("_Base:")); gtk_grid_attach(grid, label, 0, 1, 1, 1), combo = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new_with_entry()); d.base = gtk_bin_get_child(GTK_BIN(combo)); set_entry(d.base, 2, label, "2..36"); g_signal_connect(d.base, "insert-text", G_CALLBACK(on_base_insert_text), NULL); gtk_combo_box_text_append_text(combo, "2"); gtk_combo_box_text_append_text(combo, "8"); gtk_combo_box_text_append_text(combo, "10"); gtk_combo_box_text_append_text(combo, "16"); #if GTK_CHECK_VERSION(3, 0, 0) gtk_grid_attach(grid, GTK_WIDGET(combo), 1, 1, 2, 1); gtk_widget_set_hexpand(GTK_WIDGET(combo), TRUE); #else gtk_table_attach(grid, GTK_WIDGET(combo), 1, 3, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); #endif label = gtk_label_new(_("Letters:")); gtk_widget_set_tooltip_text(label, case_tip); gtk_grid_attach(grid, label, 3, 1, 1, 1); upper = gtk_radio_button_new_with_mnemonic(NULL, _("_Upper")); gtk_widget_set_tooltip_text(upper, case_tip); gtk_grid_attach(grid, upper, 4, 1, 1, 1); d.lower = gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(upper)); gtk_widget_set_tooltip_text(label, case_tip); label = gtk_label_new_with_mnemonic(_("_Lower")); gtk_widget_set_tooltip_text(label, case_tip); gtk_container_add(GTK_CONTAINER(d.lower), label); gtk_grid_attach(grid, d.lower, 5, 1, 1, 1); d.prefix = gtk_check_button_new_with_mnemonic(_("Base _prefix")); gtk_widget_set_tooltip_text(d.prefix, _("0 for octal, 0x for hex, + for positive decimal")); gtk_grid_attach(grid, d.prefix, 1, 2, 2, 1); label = gtk_label_new(_("Padding:")); gtk_grid_attach(grid, label, 3, 2, 1, 1); space = gtk_radio_button_new_with_mnemonic(NULL, _("Sp_ace")); gtk_grid_attach(grid, space, 4, 2, 1, 1); d.zero = gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(space)); label = gtk_label_new_with_mnemonic(_("_Zero")); gtk_container_add(GTK_CONTAINER(d.zero), label); gtk_grid_attach(grid, d.zero, 5, 2, 1, 1); button = gtk_button_new_from_stock(GTK_STOCK_OK); g_signal_connect(button, "clicked", G_CALLBACK(on_insert_numbers_ok_clicked), &d); gtk_box_pack_end(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(d.dialog))), button, TRUE, TRUE, 0); #if GTK_CHECK_VERSION(2, 18, 0) gtk_widget_set_can_default(button, TRUE); #else GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); #endif gtk_widget_grab_default(button); gtk_spin_button_set_value(GTK_SPIN_BUTTON(d.start), start_value); gtk_spin_button_set_value(GTK_SPIN_BUTTON(d.step), step_value); base_text = g_strdup_printf("%d", base_value); gtk_entry_set_text(GTK_ENTRY(d.base), base_text); g_free(base_text); gtk_button_clicked(GTK_BUTTON(lower_case ? d.lower : upper)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(d.prefix), base_prefix); gtk_button_clicked(GTK_BUTTON(pad_zeros ? d.zero : space)); gtk_widget_show_all(d.dialog); result = gtk_dialog_run(GTK_DIALOG(d.dialog)); if (result == GTK_RESPONSE_ACCEPT) { if (can_insert_numbers()) { if (end_line - start_line < 1000) { /* quick version */ gtk_widget_hide(d.dialog); insert_numbers(NULL); } else { gboolean cancel = FALSE; gtk_widget_set_sensitive(GTK_WIDGET(grid), FALSE); gtk_widget_set_sensitive(button, FALSE); update_display(); g_signal_connect(d.dialog, "response", G_CALLBACK(on_insert_numbers_response), &cancel); insert_numbers(&cancel); } } else plugin_beep(); /* reloaded or something */ } gtk_widget_destroy(d.dialog); }