void main_app_init() { pulse_get_time_date(¤t_time); return_to_clock_screen(); // Callback to handle button waking up processor pulse_register_callback(ACTION_WOKE_FROM_BUTTON, &return_to_clock_screen); }
void get_tz_data(int timezone, struct pulse_time_tm *time, char *city_buffer) { char city_name[TIMEZONE_FIELD_WIDTH]; pulse_get_time_date(time); time_add_hours(time, timezone - LOCAL_TIMEZONE); spiflash_read(TIMEZONE_TABLE_OFFSET + ((timezone + 11) * TIMEZONE_FIELD_WIDTH), city_name, TIMEZONE_FIELD_WIDTH); sprintf(city_buffer, "%+d %s", timezone, city_name); }
void update_time_display() { pulse_blank_canvas(); pulse_get_time_date(¤t_time); printf("The time is\n%d:%0.2d:%0.2d\n", current_time.tm_hour, current_time.tm_min, current_time.tm_sec); }
// This function is called once after the watch has booted up // and the OS has loaded void main_app_init() { struct pulse_time_tm current_time; pulse_get_time_date(¤t_time); uint32_t sec = current_time.tm_sec; srand(sec); //get_ready(); printf("Click to start\n"); }
// Main loop. This function is called frequently. // No blocking calls are allowed in this function or else the watch will reset. // The inPulse watchdog timer will kick in after 5 seconds if a blocking // call is made. void main_app_loop() { pulse_get_time_date(¤t_time); if(current_screen == SCREEN_CLOCK) { // Update once a minute if(current_min != current_time.tm_min) { current_min = current_time.tm_min; pulse_blank_canvas(); // Draw clock render_clock(clock_color); update_bluetooth_icon(bt_connected); } } }
void get_utc(struct pulse_time_tm *utc) { pulse_get_time_date(utc); time_add_hours(utc, -LOCAL_TIMEZONE); }
void main_app_loop() { if (current_screen == SCREEN_GAMEPLAY) { time_now_ms = pulse_get_millis(); if (time_now_ms - time_last_box_drawn_ms >= game_speed) { score++; move_surfaces(); int this_height = ball_y; ceiling = false; if (jump_ticks > 0) { clear_ball(ball_x, ball_y); if (ball_y-15 >=2) { ball_y = ball_y - 2; jump_ticks--; } else { jump_ticks--; ceiling = true; } } else if (ball_y < SCREEN_HEIGHT-112) { if ((ball_y+1 < SCREEN_HEIGHT-112) || ((surface_start_x[6]-4 > 20) || (surface_length_x[6]+surface_start_x[6] < 20))) { clear_ball(ball_x, ball_y); ball_y = ball_y + 2; } } else if (ball_y < SCREEN_HEIGHT-96) { if ((ball_y+1 < SCREEN_HEIGHT-96) || ((surface_start_x[5]-4 > 20) || (surface_length_x[5]+surface_start_x[5] < 20))) { clear_ball(ball_x, ball_y); ball_y = ball_y + 2; } } else if (ball_y < SCREEN_HEIGHT-80) { if ((ball_y+1 < SCREEN_HEIGHT-80) || ((surface_start_x[4]-4 > 20) || (surface_length_x[4]+surface_start_x[4] < 20))) { clear_ball(ball_x, ball_y); ball_y = ball_y + 2; } } else if (ball_y < SCREEN_HEIGHT-64) { if ((ball_y+1 < SCREEN_HEIGHT-64) || ((surface_start_x[3]-4 > 20) || (surface_length_x[3]+surface_start_x[3] < 20))) { clear_ball(ball_x, ball_y); ball_y = ball_y + 2; } } else if (ball_y < SCREEN_HEIGHT-48) { if ((ball_y+1 < SCREEN_HEIGHT-48) || ((surface_start_x[2]-4 > 20) || (surface_length_x[2]+surface_start_x[2] < 20))) { clear_ball(ball_x, ball_y); ball_y = ball_y + 2; } } else if (ball_y < SCREEN_HEIGHT-32) { if ((ball_y+1 < SCREEN_HEIGHT-32) || ((surface_start_x[1]-4 > 20) || (surface_length_x[1]+surface_start_x[1] < 20))) { clear_ball(ball_x, ball_y); ball_y = ball_y + 2; } } else if (ball_y < SCREEN_HEIGHT-16) { if ((ball_y+1 < SCREEN_HEIGHT-16) || ((surface_start_x[0]-4 > 20) || (surface_length_x[0]+surface_start_x[0] < 20))) { clear_ball(ball_x, ball_y); ball_y = ball_y + 2; } } else { clear_ball(ball_x, ball_y); ball_y = ball_y + 2; } draw_ball(ball_x, ball_y, green); if ((this_height == ball_y) && (!ceiling)) { jumps_available = 2; } if (ball_y >= SCREEN_HEIGHT-1) { game_over(); } time_last_box_drawn_ms = time_now_ms; } else if (current_screen == SCREEN_CLOCK) { pulse_get_time_date(¤t_time); } } }
// Main loop. void main_app_loop() { if (current_screen == SCREEN_GAMEPLAY) { // Find out how long the processor has been active (since boot or since sleep) time_now_ms = pulse_get_millis(); // Check if it's been at least 10 ms since the box was last drawn if (time_now_ms - time_last_box_drawn_ms >= game_speed) { score++; // Change the color and speed up the walls when certain scores are reached switch(score) { case 800: wall_color = teal; game_speed-=2; break; case 1600: wall_color = blue; game_speed-=2; break; case 2400: wall_color = purple; game_speed-=2; break; case 3200: wall_color = pink; game_speed-=2; break; case 4000: wall_color = orange; game_speed-=2; break; case 4800: wall_color = red; game_speed-=2; break; } // Erase the old ball and walls by drawing over them draw_ball(ball_x,ball_y, COLOR_BLACK24); for (int i = 0; i < NUM_WALLS; i++) draw_wall(wall_y[i],wall_gap_x[i], COLOR_BLACK24); // Move the ball based on user input if(press && ball_x < SCREEN_WIDTH - BALL_SIZE) ball_x++; else if (!press && ball_x > 0) ball_x--; // Move the walls up for (int i = 0; i < NUM_WALLS; i++) move_wall(i); // Check for collisions between the ball and the wall bool collision = false; for (int i = 0; i < NUM_WALLS; i++) { if ((ball_y == wall_y[i] - BALL_SIZE + 1 || ball_y == wall_y[i] - BALL_SIZE)&& (ball_x < wall_gap_x[i] || ball_x > wall_gap_x[i] + GAP_WIDTH - BALL_SIZE)) { ball_y = wall_y[i] - BALL_SIZE; collision = true; } } // check if ball reached the top if (ball_y == start_y) game_over(); else { if (!collision && ball_y < SCREEN_HEIGHT-BALL_SIZE-1) ball_y = (ball_y + 1); // Draw the new box and walls draw_game_elements(); // update the time_last_box_draw_ms variable time_last_box_drawn_ms = time_now_ms; } } } else if (current_screen == SCREEN_CLOCK) pulse_get_time_date(¤t_time); }
void main_app_loop(void) { uint8_t umpl_got; const uint64_t millis = pulse_get_millis(); // If the not-charging state has not been toggled in the last // 30 seconds, schedule a power down soon. if (not_charging && millis - not_charging > 60000) { if (!shutdown_scheduled) pulse_update_power_down_timer(1); shutdown_scheduled = 1; return; } /* The umpl_input_handler is nonblocking. * It will read a packet off the debug serial * port, and copy the rotation matrix payload * to the provided buffer. */ umpl_got = umpl_input_handler(default_m); if (umpl_got) dbg_putc((char)0); // (for debugging) camera_setup_rmat(&camera, 4000, rmats[selected_mat]); #if 1 pixel_t temp_pixels[ARRAY_COUNT(pixels)]; wireframe_draw( &camera, ARRAY_COUNT(vertices), vertices, ARRAY_COUNT(edges), edges, pixels, temp_pixels ); #else for (int i = 0 ; i < ARRAY_COUNT(vertices) ; i++) { const vertex_t * const v = &vertices[i]; pixel_t * const p = &pixels[i]; draw_pixel(COLOR_BLACK24, p->x, p->y); camera_project(&camera, v, p); draw_pixel(COLOR_GREEN, p->x, p->y); } #endif // Update the clock once per minute struct pulse_time_tm now; pulse_get_time_date(&now); if (last_sec == now.tm_sec) return; last_sec = now.tm_sec; if (last_min != now.tm_min) pulse_blank_canvas(); last_min = now.tm_min; char buf[16]; sprintf(buf, "%02d:%02d", now.tm_hour, now.tm_min ); draw_monostring(8, VSCREEN_HEIGHT - FONT_HEIGHT - 1, COLOR_GREEN, buf); }
void print_time_into_text_buffer() { pulse_get_time_date(¤t_time); sprintf(clock_text_buffer, "%d:%02d", current_time.tm_hour, current_time.tm_min); }