mirror of
https://github.com/marqs85/ossc.git
synced 2025-02-05 12:33:24 +00:00
Don't save initconfig every time the physical input and profile change
This spares the Flash from some unnecessary writes. If the profile tied to a physical input changes, this change will be reflected in the initconfig when the new profile is loaded.
This commit is contained in:
parent
1979bdb333
commit
ab61fd0c67
@ -890,7 +890,7 @@ int main()
|
||||
// The input changed, so load the appropriate profile
|
||||
if (profile_sel != input_profiles[phy_input_sel]) {
|
||||
profile_sel = input_profiles[phy_input_sel];
|
||||
load_profile();
|
||||
read_userdata(profile_sel);
|
||||
}
|
||||
|
||||
cm.avinput = target_mode;
|
||||
|
@ -57,7 +57,6 @@ int write_userdata(alt_u8 entry)
|
||||
((ude_initcfg*)databuf)->data_len = sizeof(ude_initcfg) - offsetof(ude_initcfg, last_profile);
|
||||
memcpy(((ude_initcfg*)databuf)->last_profile, input_profiles, sizeof(input_profiles));
|
||||
((ude_initcfg*)databuf)->last_input = cm.avinput;
|
||||
((ude_initcfg*)databuf)->last_phy_input = phy_input_sel;
|
||||
memcpy(((ude_initcfg*)databuf)->keys, rc_keymap, sizeof(rc_keymap));
|
||||
retval = write_flash_page(databuf, sizeof(ude_initcfg), (USERDATA_OFFSET+entry*SECTORSIZE)/PAGESIZE);
|
||||
if (retval != 0)
|
||||
@ -141,7 +140,7 @@ int read_userdata(alt_u8 entry)
|
||||
input_profiles[i] = ((ude_initcfg*)databuf)->last_profile[i];
|
||||
if (((ude_initcfg*)databuf)->last_input < AV_LAST)
|
||||
target_mode = ((ude_initcfg*)databuf)->last_input;
|
||||
profile_sel = input_profiles[((ude_initcfg*)databuf)->last_phy_input];
|
||||
profile_sel = input_profiles[0]; // Arbitrary default
|
||||
memcpy(rc_keymap, ((ude_initcfg*)databuf)->keys, sizeof(rc_keymap));
|
||||
printf("RC data read (%u bytes)\n", sizeof(rc_keymap));
|
||||
}
|
||||
|
@ -48,7 +48,6 @@ typedef struct {
|
||||
alt_u16 data_len;
|
||||
alt_u8 last_profile[3];
|
||||
avinput_t last_input;
|
||||
phyinput_t last_phy_input;
|
||||
alt_u16 keys[REMOTE_MAX_KEYS];
|
||||
} __attribute__((packed, __may_alias__)) ude_initcfg;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user