#include #include #include #include static daguerre::fixed_font *font; std::string time_to_string(time_t t) { //convert to edt - TODO: timezones in euler t -= 4 * 3600 * 1024; tm *gt = gmtime(&t); int hour = (gt->tm_hour - 1) % 12 + 1; int min = gt->tm_min; int sec = gt->tm_sec; bool pm = gt->tm_hour >= 12; std::string s; s.resize(8); s[0] = hour / 10 + '0'; s[1] = hour % 10 + '0'; s[3] = min / 10 + '0'; s[4] = min % 10 + '0'; s[2] = sec % 2 == 0 ? ':' : ' '; s[5] = ' '; s[6] = pm ? 'p' : 'a'; s[7] = 'm'; if (s[0] == '0') s.erase(0, 1); return s; } int main() { font = new daguerre::fixed_font( daguerre::try_load_psf("/assets/terminus/10x18-bold.psf").value()); time_t t = euler::syscall::get_time(); pake::widgets::fixed_text *text = new pake::widgets::fixed_text(time_to_string(t), font, euler::syscall::encode_color(0xaa, 0xaa, 0xaa), euler::syscall::encode_color(0x00, 0x00, 0x00), pake::halign::center, pake::valign::center); pake::window w(90, 28, "Clock"); w.set_root(std::unique_ptr(text)); w.render_and_send_to_compositor(); w.show(); while (1) { euler::syscall::sleep(1024 - t % 1024); t = euler::syscall::get_time(); text->set_text(time_to_string(t)); w.render_and_send_to_compositor(); } }