push for windows

This commit is contained in:
Rens Pastoor
2025-06-17 10:10:15 +02:00
parent 04072d831e
commit 12135deea1
15 changed files with 54 additions and 53 deletions

Binary file not shown.

View File

@@ -19,16 +19,13 @@ void watch_registers_get_config_settings(uint8_t config, bool* is_paused, time_f
}
void watch_registers_set_time_hours(uint8_t* time_bits_low, uint8_t* time_bits_high, uint8_t hours){
if (hours > 11) hours = 11;
*time_bits_high = (*time_bits_high & 0x0F) | ((hours & 0x0F) << 4); // Set the upper nibble
}
void watch_registers_set_time_minutes(uint8_t* time_bits_low, uint8_t* time_bits_high, uint8_t minutes){
if (minutes > 59) minutes = 59;
*time_bits_high = (*time_bits_high & 0xF0) | ((minutes >> 2) & 0x0F); // Set the lower nibble of MSB
*time_bits_low = (*time_bits_low & 0x3F) | ((minutes & 0x03) << 6); // Set the upper two bits of LSB
}
void watch_registers_set_time_seconds(uint8_t* time_bits_low, uint8_t* time_bits_high, uint8_t seconds){
if (seconds > 59) seconds = 59;
*time_bits_low = (*time_bits_low & 0xC0) | (seconds & 0x3F); // Set the lower 6 bits of LSB
}
void watch_registers_get_time(uint8_t time_bits_low, uint8_t time_bits_high, uint8_t* hours, uint8_t* minutes, uint8_t* seconds){
@@ -38,18 +35,13 @@ void watch_registers_get_time(uint8_t time_bits_low, uint8_t time_bits_high, uin
}
void watch_registers_set_date_year(uint8_t* date_bits_low, uint8_t* date_bits_high, uint8_t year){
if (year > 127) year = 127; // Maximum year value is 127 (0x7F) for 7 bits
*date_bits_low = (*date_bits_low & 0x80) | (year & 0x7F); // Set the lower 2 bits of LSB
}
void watch_registers_set_date_month(uint8_t* date_bits_low, uint8_t* date_bits_high, uint8_t month){
if (month > 12) month = 12; // Maximum month value is 12
else if (month < 1) month = 1; // Minimum month value is 1
*date_bits_high = (*date_bits_high & 0xF8) | ((month >> 1) & 0x07);
*date_bits_low = (*date_bits_low & 0x7F) | ((month & 0x01) << 7);
}
void watch_registers_set_date_day_of_month(uint8_t* date_bits_low, uint8_t* date_bits_high,uint8_t day_of_month){
if (day_of_month > 31) day_of_month = 31; // Maximum day of month value is 31
else if (day_of_month < 1) day_of_month = 1; // Minimum day of month value is 1
*date_bits_high = (*date_bits_high & 0x07) | ((day_of_month & 0x1F) << 3); // Set the upper 5 bits of MSB
}
void watch_registers_get_date(uint8_t date_bits_low, uint8_t date_bits_high, uint8_t* year, uint8_t* month, uint8_t* day_of_month){

View File

@@ -59,6 +59,25 @@ void test_setting_get_config_settings(void){
watch_registers_get_config_settings(config, &is_paused, &format, &interval);
TEST_ASSERT_EQUAL(TIME_EVERY_1_SECOND, interval);
}
void test_setting_get_config_settings2(void){
uint8_t config = 0xAA; // 0b00000000 so time is updated, time format hour:minute, time refresh not updated
bool is_paused;
time_format format;
time_update_interval interval;
watch_registers_get_config_settings(config, &is_paused, &format, &interval);
TEST_ASSERT_EQUAL(true, is_paused);
TEST_ASSERT_EQUAL(0, format);
TEST_ASSERT_EQUAL(0b01, interval);
config = 0x55;
watch_registers_get_config_settings(config, &is_paused, &format, &interval);
TEST_ASSERT_EQUAL(false, is_paused);
TEST_ASSERT_EQUAL(1, format);
TEST_ASSERT_EQUAL(0b10, interval);
}
//
//time
void test_time_set_hours(void){
@@ -215,6 +234,7 @@ void run_watch_tests()
MY_RUN_TEST(test_setting_set_config_time_format);
MY_RUN_TEST(test_setting_set_config_time_update_interval);
MY_RUN_TEST(test_setting_get_config_settings);
MY_RUN_TEST(test_setting_get_config_settings2);
MY_RUN_TEST(test_time_set_hours);
MY_RUN_TEST(test_time_set_minutes);
@@ -227,7 +247,5 @@ void run_watch_tests()
MY_RUN_TEST(test_date_get_date);
MY_RUN_TEST(test_full_watch_configuration);
MY_RUN_TEST(test_full_datetime_overflow_setup);
UnityUnregisterSetupTearDown();
}