diff --git a/run_tree/raspi/arm64/debug/lumenarium b/run_tree/raspi/arm64/debug/lumenarium index c881788..eed03e6 100755 Binary files a/run_tree/raspi/arm64/debug/lumenarium and b/run_tree/raspi/arm64/debug/lumenarium differ diff --git a/run_tree/raspi/arm64/prod/lumenarium b/run_tree/raspi/arm64/prod/lumenarium deleted file mode 100755 index 3190fb9..0000000 Binary files a/run_tree/raspi/arm64/prod/lumenarium and /dev/null differ diff --git a/src_v2/user_space/incenter_interface_connection.c b/src_v2/user_space/incenter_interface_connection.c index b7feda1..c72d088 100644 --- a/src_v2/user_space/incenter_interface_connection.c +++ b/src_v2/user_space/incenter_interface_connection.c @@ -127,10 +127,11 @@ incenter_handle_sliding_scale_msg(Incenter_State* ins, Incenter_Scene scene, cha case 'C': { live_answers_input_r32(ins, scene, ins->input_pct); - ins->scene_mode = Incenter_SceneMode_Passive; - ins->scene_time = 0; } break; } + + ins->scene_mode = Incenter_SceneMode_Passive; + ins->scene_time = 0; ins->input_pct = clamp(0, ins->input_pct, 1); } diff --git a/src_v2/user_space/incenter_live_answers.c b/src_v2/user_space/incenter_live_answers.c index fe21182..1e05ab4 100644 --- a/src_v2/user_space/incenter_live_answers.c +++ b/src_v2/user_space/incenter_live_answers.c @@ -71,7 +71,22 @@ live_answers_load(Incenter_Scene scene, Allocator* allocator) Live_Answers_File result = {0}; // Read the File +#define USING_PLATFORM_LAYER 0 +#if !USING_PLATFORM_LAYER result.path = string_f(allocator, "data/live_data/%s.incenterdata", scene.name); + Data file_data = {0}; + FILE* file = fopen((const char*)result.path.str, "rb"); + if (file) { + fseek(file, 0, SEEK_END); + s32 size = ftell(file); + fseek(file, 0, SEEK_SET); + file_data.base = allocator_alloc(allocator, size); + file_data.size = fread((void*)file_data.base, size, 1, file); + fclose(file); + } else { + printf("Creating live data file: %s\n", (char*)result.path.str); + } +#else File_Handle file = os_file_open(result.path, FileAccess_Read, FileCreate_OpenExisting); Data file_data = {0}; if (file.value != 0) @@ -79,6 +94,7 @@ live_answers_load(Incenter_Scene scene, Allocator* allocator) file_data = os_file_read_all(file, allocator); os_file_close(file); } +#endif // Obtain structure of file data if (file_data.size > 1) { @@ -114,6 +130,14 @@ live_answers_save(Live_Answers_File file, Live_Answers_File_Bucket* new_bucket) return; } +#if !USING_PLATFORM_LAYER + FILE* fh = fopen((const char*)file.path.str, "wb"); + if (!fh) { + printf("Error: Unable to open live data file for writing\n"); + printf(" Live Data File: %.*s\n", str_varg(file.path)); + return; + } +#else File_Handle fh = os_file_open(file.path, FileAccess_Write, FileCreate_OpenAlways); if (fh.value == 0) { printf("Error: Unable to open live data file for writing\n"); @@ -124,31 +148,52 @@ live_answers_save(Live_Answers_File file, Live_Answers_File_Bucket* new_bucket) return; } - +#endif + Data existing_data = { .base = (u8*)file.header, .size = sizeof(Live_Answers_File_Header) + (sizeof(Live_Answers_File_Bucket) * file.header->buckets_count) }; +#if !USING_PLATFORM_LAYER + s32 size_written = fwrite((void*)existing_data.base, 1, existing_data.size, fh); + if (size_written != existing_data.size) { + printf("Unable to write full file: %.*s\n", str_varg(file.path)); + printf(" Size Needed: %lu, Size Written: %d\n", existing_data.size, size_written); + } +#else if (!os_file_write(fh, existing_data)) { printf("Error: Could not write existing data to Live Data File\n"); printf(" Live Data File: %.*s\n", str_varg(file.path)); } +#endif if (new_bucket) { Data new_data = { .base = (u8*)new_bucket, .size = sizeof(Live_Answers_File_Bucket) }; +#if !USING_PLATFORM_LAYER + size_written = fwrite(new_data.base, 1, new_data.size, fh); + if (size_written != new_data.size) { + printf("Unable to add new data to file %.*s\n", str_varg(file.path)); + printf(" Size Needed: %lu, Size Written: %d\n", new_data.size, size_written); + } +#else if (!os_file_write(fh, new_data)) { printf("Error: Could not write new bucket data to Live Data File\n"); printf(" Live Data File: %.*s\n", str_varg(file.path)); } +#endif } +#if !USING_PLATFORM_LAYER + fclose(fh); +#else os_file_close(fh); +#endif } -#if 0 +#if 1 # define MAYBE_SKIP_SAVING_INPUT #else # define MAYBE_SKIP_SAVING_INPUT return @@ -188,7 +233,7 @@ live_answers_input_u32(Incenter_State* ins, Incenter_Scene scene, u32 value) live_answers_save(file, new_bucket); - scratch_release(scratch); + 4scratch_release(scratch); } internal void diff --git a/src_v2/user_space/incenter_patterns.c b/src_v2/user_space/incenter_patterns.c index 3c9a7f7..8fe9aff 100644 --- a/src_v2/user_space/incenter_patterns.c +++ b/src_v2/user_space/incenter_patterns.c @@ -995,6 +995,12 @@ pattern_bar_chart(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Inc pattern_add_bar_chart(pixels, strips, ins, scene, scene.data[0].year, scene.data[0].month, xray_ramp); } +global bool needs_reset = true; +global u32 year_max = 0; +global Incenter_Month_Id month_max = 0; +global u32 year_at = 0; +global Incenter_Month_Id month_at = 0; +global r32 month_start_time = 0; void pattern_bar_chart_over_time(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) @@ -1002,15 +1008,9 @@ pattern_bar_chart_over_time(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array s Incenter_Scene scene = ins->scenes[ins->scene_at]; if (!scene.data) return; - local_persist s32 last_scene_at = -1; - local_persist u32 year_max = 0; - local_persist Incenter_Month_Id month_max = 0; - local_persist u32 year_at = 0; - local_persist Incenter_Month_Id month_at = 0; - local_persist r32 month_start_time = 0; - if (last_scene_at != ins->scene_at) + if (needs_reset) { - last_scene_at = ins->scene_at; + needs_reset = false; // Determine what the end of the data set is for (u32 row_i = 0; row_i < scene.data_len; row_i++) @@ -1027,7 +1027,7 @@ pattern_bar_chart_over_time(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array s month_start_time = ins->scene_time; } - r32 month_duration = 2; + r32 month_duration = 1; r32 time_at_month = ins->scene_time - month_start_time; if (time_at_month > month_duration) { @@ -1136,7 +1136,7 @@ pattern_felt_isolated_passive(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array { Incenter_Data_Row row = scene.data[row_i]; Assembly_Strip strip = strips.strips[row.id]; - u32 pixel_start = strip.pixels_len - (row.prop * strip.pixels_len); + s32 pixel_start = (row.prop * strip.pixels_len); r32 row_offset = (.1439f * row_i); r32 b = pm_sinf_01(ins->scene_time + row_offset); @@ -1146,9 +1146,10 @@ pattern_felt_isolated_passive(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array r32 grow_pct = clamp(0, grow_time, grow_duration) / grow_duration; r32 grow_pct_smoothed = pm_easeinout_cubic_r32(grow_pct); - u32 pixels_on = (strip.pixels_len - pixel_start) * grow_pct_smoothed; - u32 pixel_stop = clamp(pixel_start + 1, pixel_start + pixels_on, strip.pixels_len); - for (u32 pixel_i = pixel_start; pixel_i < pixel_stop; pixel_i++) + s32 pixels_on = pixel_start * grow_pct_smoothed; + s32 pixel_stop = clamp(0, pixel_start - pixels_on, pixel_start - 1); + for (u32 pixel_i = + pixel_stop; pixel_i < pixel_start; pixel_i++) { u32 pixel_index = strip.pixels[pixel_i]; pixels.pixels[pixel_index] = pattern_felt_isolated_color( diff --git a/src_v2/user_space/incenter_scenes.c b/src_v2/user_space/incenter_scenes.c index a88e549..82baa1d 100644 --- a/src_v2/user_space/incenter_scenes.c +++ b/src_v2/user_space/incenter_scenes.c @@ -105,7 +105,7 @@ incenter_scene_descs_init() }, .data = question_7_data, .data_len = question_7_len, - .kind = Incenter_SceneKind_SlidingScale, + .kind = Incenter_SceneKind_YesOrNo, }; incenter_scene_descs[Incenter_Scene_Question_ConnectionFriendsFamily] = (Incenter_Scene){ @@ -186,14 +186,14 @@ incenter_scene_descs_init() }, .data = question_18_data, .data_len = question_18_len, - .kind = Incenter_SceneKind_YesOrNo, + .kind = Incenter_SceneKind_SlidingScale, }; incenter_scene_descs[Incenter_Scene_Question_BelieveScienceRenewableTech] = (Incenter_Scene){ .name = "BelieveScienceRenewableTech", .patterns = { - [Incenter_SceneMode_Intro] = pattern_bar_chart_random_fill, - [Incenter_SceneMode_Passive] = pattern_bar_chart_random_fill, + [Incenter_SceneMode_Intro] = pattern_felt_isolated_intro , + [Incenter_SceneMode_Passive] = pattern_felt_isolated_passive, }, .data = question_19_data, .data_len = question_19_len, @@ -203,8 +203,8 @@ incenter_scene_descs_init() incenter_scene_descs[Incenter_Scene_Question_StriveMoreEcoFriendly] = (Incenter_Scene){ .name = "StriveMoreEcoFriendly", .patterns = { - [Incenter_SceneMode_Intro] = pattern_bar_chart, - [Incenter_SceneMode_Passive] = pattern_bar_chart, + [Incenter_SceneMode_Intro] = pattern_bar_chart_over_time, + [Incenter_SceneMode_Passive] = pattern_bar_chart_over_time, }, // .data = question_22_data, // .data_len = question_22_len, diff --git a/src_v2/user_space/incenter_user_space.c b/src_v2/user_space/incenter_user_space.c index c9c3b6d..6618231 100644 --- a/src_v2/user_space/incenter_user_space.c +++ b/src_v2/user_space/incenter_user_space.c @@ -25,6 +25,14 @@ incenter_scenes_init(Incenter_State* ins, u32 cap, Allocator* a) internal void incenter_reset_inputs(Incenter_State* ins) { + // reset bar chart over time + needs_reset = true; + year_max = 0; + month_max = 0; + year_at = 0; + month_at = 0; + month_start_time = 0; + // reset inputs ins->input_pct = 0.5f; ins->input_option = 0; diff --git a/todo.txt b/todo.txt index ce25e2b..0355424 100644 --- a/todo.txt +++ b/todo.txt @@ -3,6 +3,8 @@ - FILE IO bugs x Timeout to idle +LUSIO Light festival + - kids love this thing "THATS THE COOLEST" - conversation about "People probably haven't talked about their covid experience yet, this is really good." - "This is the most peaceful I've felt in a long time"