convert to new image format

This commit is contained in:
Theis Pieter Hollebeek 2024-04-03 09:02:23 +02:00
parent c1ed7b057a
commit 0e60faa538
2 changed files with 21 additions and 1720 deletions

File diff suppressed because one or more lines are too long

View File

@ -2,6 +2,7 @@
MKRIoTCarrier carrier;
#define MAX_INT 4 // (så kan den bruges som pi)
#define SIZE 120
#include "pitches.h"
#include "image.c"
@ -9,10 +10,7 @@ MKRIoTCarrier carrier;
void setup() {
Serial.begin(9600);
carrier.begin();
carrier.display.fillScreen(ST77XX_BLACK); // Start med en ren skærm
Serial.println("start");
int red_sun_in_the_sky[] = {
NOTE_D6, NOTE_D6, NOTE_D6, NOTE_D6, NOTE_D6, NOTE_F6, NOTE_D6, NOTE_AS5,
@ -35,7 +33,6 @@ NOTE_D6, NOTE_AS5, NOTE_G5, NOTE_G5, 0
2,2,2,2,2,2,4,
2,4,2,2,4,2,
4,4,2,2,4
};
for (int note_idx = 0; note_idx < sizeof(noteDurations) / sizeof(int); note_idx++) {
@ -48,37 +45,18 @@ NOTE_D6, NOTE_AS5, NOTE_G5, NOTE_G5, 0
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
delay(noteDuration);
// stop the tone playing:
carrier.Buzzer.noSound();
delay(noteDuration);
}
}
inline int color_u8_to_u6(int v) {
const double conversion_ratio = 63.0 / 255.0;
return (int)(v * conversion_ratio);
}
inline int color_u8_to_u5(int v) {
const double conversion_ratio = 31.0 / 255.0;
return (int)(v * conversion_ratio);
}
void loop() {
Serial.println(":3");
for (int x = 0; x < SIZE; x++) {
for (int y = 0; y < SIZE; y++) {
int idx = 3 * (y * SIZE + x);
// for some reason
// red = 5 bytes
// green = 6 bytes
// blue = 5 bytes
int r = (int)gimp_image[idx] & 0xFF;
int g = (int)gimp_image[idx + 1] & 0xFF;
int b = (int)gimp_image[idx + 2] & 0xFF;
int color = (color_u8_to_u5(r) << 11) | (color_u8_to_u6(g) << 5) | color_u8_to_u5(b);
int idx = y * SIZE + x;
unsigned short color = gimp_image[idx];
carrier.display.fillRect(x * 2, y * 2, 2, 2, color);
}
}
delay(2500); // Vent lidt før næste måling
delay(2500);
}