Fixed type warnings and errors with virtual builds

Virtual builds use their own versions of pgm_read_...
Some of those caused warnings that needed to be silenced by proper casting.
In one place in LEDEffect-BootAnimation, this reveiled an error where a word was
read and then assinged to a byte value. This was fixed as well.

Signed-off-by: Florian Fleissner <florian.fleissner@inpartik.de>
pull/640/head
Florian Fleissner 6 years ago committed by Jesse Vincent
parent 7326be589f
commit ca4f40dbb6

@ -24,7 +24,7 @@ namespace kaleidoscope {
inline inline
Key keyFromKeymap(uint8_t layer, KeyAddr key_addr) { Key keyFromKeymap(uint8_t layer, KeyAddr key_addr) {
return pgm_read_word(&keymaps_linear[layer][key_addr.toInt()]); return pgm_read_word(&keymaps_linear[layer][key_addr.toInt()].raw);
} }
namespace internal { namespace internal {

@ -48,7 +48,7 @@ void Cycle::replace(uint8_t cycle_size, const Key cycle_steps[]) {
uint8_t idx = cycle_count_ % cycle_size; uint8_t idx = cycle_count_ % cycle_size;
Key key; Key key;
key.raw = pgm_read_word(cycle_steps + idx); key.raw = pgm_read_word(&cycle_steps[idx].raw);
replace(key); replace(key);
} }

@ -78,9 +78,9 @@ void WavepoolEffect::TransientLEDMode::raindrop(uint8_t x, uint8_t y, int8_t *pa
// this is a lot smaller than the standard library's rand(), // this is a lot smaller than the standard library's rand(),
// and still looks random-ish // and still looks random-ish
uint8_t WavepoolEffect::TransientLEDMode::wp_rand() { uint8_t WavepoolEffect::TransientLEDMode::wp_rand() {
static uint16_t offset = 0x400; static intptr_t offset = 0x400;
offset = ((offset + 1) & 0x4fff) | 0x400; offset = ((offset + 1) & 0x4fff) | 0x400;
return (Kaleidoscope.millisAtCycleStart() / MS_PER_FRAME) + pgm_read_byte(offset); return (Kaleidoscope.millisAtCycleStart() / MS_PER_FRAME) + pgm_read_byte((const uint8_t *)offset);
} }
void WavepoolEffect::TransientLEDMode::update(void) { void WavepoolEffect::TransientLEDMode::update(void) {

@ -132,7 +132,7 @@ EventHandlerResult Leader::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, u
return EventHandlerResult::EVENT_CONSUMED; return EventHandlerResult::EVENT_CONSUMED;
} }
action_t leaderAction = (action_t) pgm_read_ptr(&(dictionary[action_index].action)); action_t leaderAction = (action_t) pgm_read_ptr((void const **) & (dictionary[action_index].action));
(*leaderAction)(action_index); (*leaderAction)(action_index);
return EventHandlerResult::EVENT_CONSUMED; return EventHandlerResult::EVENT_CONSUMED;

@ -174,26 +174,26 @@ Key Macros_::lookupAsciiCode(uint8_t ascii_code) {
key.keyCode = Key_Spacebar.keyCode; key.keyCode = Key_Spacebar.keyCode;
break; break;
case 0x21 ... 0x30: case 0x21 ... 0x30:
key.raw = pgm_read_word(&ascii_to_key_map[ascii_code - 0x21]); key.raw = pgm_read_word(&ascii_to_key_map[ascii_code - 0x21].raw);
break; break;
case 0x31 ... 0x39: case 0x31 ... 0x39:
key.keyCode = Key_1.keyCode + ascii_code - 0x31; key.keyCode = Key_1.keyCode + ascii_code - 0x31;
break; break;
case 0x3A ... 0x40: case 0x3A ... 0x40:
key.raw = pgm_read_word(&ascii_to_key_map[ascii_code - 0x3A + 16]); key.raw = pgm_read_word(&ascii_to_key_map[ascii_code - 0x3A + 16].raw);
break; break;
case 0x41 ... 0x5A: case 0x41 ... 0x5A:
key.flags = SHIFT_HELD; key.flags = SHIFT_HELD;
key.keyCode = Key_A.keyCode + ascii_code - 0x41; key.keyCode = Key_A.keyCode + ascii_code - 0x41;
break; break;
case 0x5B ... 0x60: case 0x5B ... 0x60:
key.raw = pgm_read_word(&ascii_to_key_map[ascii_code - 0x5B + 23]); key.raw = pgm_read_word(&ascii_to_key_map[ascii_code - 0x5B + 23].raw);
break; break;
case 0x61 ... 0x7A: case 0x61 ... 0x7A:
key.keyCode = Key_A.keyCode + ascii_code - 0x61; key.keyCode = Key_A.keyCode + ascii_code - 0x61;
break; break;
case 0x7B ... 0x7E: case 0x7B ... 0x7E:
key.raw = pgm_read_word(&ascii_to_key_map[ascii_code - 0x7B + 29]); key.raw = pgm_read_word(&ascii_to_key_map[ascii_code - 0x7B + 29].raw);
break; break;
} }
return key; return key;

@ -43,7 +43,7 @@ EventHandlerResult MagicCombo::beforeReportingState() {
match = false; match = false;
if (match && Kaleidoscope.hasTimeExpired(start_time_, min_interval)) { if (match && Kaleidoscope.hasTimeExpired(start_time_, min_interval)) {
ComboAction action = (ComboAction) pgm_read_ptr(&(magiccombo::combos[i].action)); ComboAction action = (ComboAction) pgm_read_ptr((void const **) & (magiccombo::combos[i].action));
(*action)(i); (*action)(i);
start_time_ = Kaleidoscope.millisAtCycleStart(); start_time_ = Kaleidoscope.millisAtCycleStart();

Loading…
Cancel
Save