fix image rendering
This commit is contained in:
parent
0e60faa538
commit
d7cbb1b9fb
6
program/README.txt
Normal file
6
program/README.txt
Normal file
@ -0,0 +1,6 @@
|
||||
The fully qualified board name is `arduino:samd:mkrwifi1010`
|
||||
|
||||
Ergo:
|
||||
|
||||
`arduino-cli compile -b arduino:samd:mkrwifi1010`
|
||||
`arduino-cli upload -b arduino:samd:mkrwifi1010`
|
File diff suppressed because one or more lines are too long
@ -41,7 +41,9 @@ void setup() {
|
||||
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
|
||||
int noteDuration = noteDurations[note_idx]/(139*8.0)*60*1000;
|
||||
Serial.println(noteDuration);
|
||||
carrier.Buzzer.sound(red_sun_in_the_sky[note_idx]);
|
||||
|
||||
/////// carrier.Buzzer.sound(red_sun_in_the_sky[note_idx]);
|
||||
|
||||
// to distinguish the notes, set a minimum time between them.
|
||||
// the note's duration + 30% seems to work well:
|
||||
delay(noteDuration);
|
2
program/sketch.yaml
Normal file
2
program/sketch.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
default_fqbn: arduino:samd:mkrwifi1010
|
||||
default_port: /dev/ttyACM0
|
@ -3,3 +3,13 @@ gimp_img_conv
|
||||
===
|
||||
|
||||
convert the 8-8-8 bit format of exporting a RGB image as a .c file from gimp into the 5-6-5 bit format the arduino we use uses.
|
||||
|
||||
instructions:
|
||||
|
||||
1. export 120x120 image as .c file to base_image.c
|
||||
|
||||
2. `./run.sh > new_image.c`
|
||||
|
||||
3. `cp new_image.c ../../program/image.c`
|
||||
|
||||
4. profit
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include "glib.h"
|
||||
#include "base_image.c"
|
||||
|
||||
@ -16,7 +17,8 @@ int color_u8_to_u5(int v) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
printf("static const unsigned short gimp_image[%d] = \"", gimp_image.width * gimp_image.height);
|
||||
printf("static const unsigned short gimp_image[%d] = {", gimp_image.width * gimp_image.height);
|
||||
bool include_comma = false;
|
||||
for (int x = 0; x < gimp_image.width; x++) {
|
||||
for (int y = 0; y < gimp_image.height; y++) {
|
||||
int idx = 3 * (y * gimp_image.width + x);
|
||||
@ -28,9 +30,14 @@ void main() {
|
||||
int g = (int)gimp_image.pixel_data[idx + 1] & 0xFF;
|
||||
int b = (int)gimp_image.pixel_data[idx + 2] & 0xFF;
|
||||
uint16_t color = (color_u8_to_u5(r) << 11) | (color_u8_to_u6(g) << 5) | color_u8_to_u5(b);
|
||||
printf("\\0x%X", color);
|
||||
if (!include_comma) {
|
||||
include_comma = true;
|
||||
} else {
|
||||
printf(", ");
|
||||
}
|
||||
printf("0x%X", color);
|
||||
}
|
||||
}
|
||||
printf("\"\n");
|
||||
printf("};\n");
|
||||
}
|
||||
|
||||
|
0
tools/gimp_img_conv/run.sh
Normal file → Executable file
0
tools/gimp_img_conv/run.sh
Normal file → Executable file
Loading…
Reference in New Issue
Block a user