-
Notifications
You must be signed in to change notification settings - Fork 497
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #537 from pimoroni/feature/galactic_unicorn
Galactic Unicorn
- Loading branch information
Showing
49 changed files
with
15,178 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
add_executable( | ||
rainbow_text | ||
rainbow_text.cpp | ||
) | ||
|
||
# Pull in pico libraries that we need | ||
target_link_libraries(rainbow_text pico_stdlib hardware_pio hardware_adc hardware_dma pico_graphics galactic_unicorn) | ||
pico_enable_stdio_usb(rainbow_text 1) | ||
|
||
# create map/bin/hex file etc. | ||
pico_add_extra_outputs(rainbow_text) | ||
|
||
|
||
|
||
add_executable( | ||
rainbow | ||
rainbow.cpp | ||
) | ||
|
||
# Pull in pico libraries that we need | ||
target_link_libraries(rainbow pico_stdlib hardware_pio hardware_adc hardware_dma pico_graphics galactic_unicorn) | ||
pico_enable_stdio_usb(rainbow 1) | ||
|
||
# create map/bin/hex file etc. | ||
pico_add_extra_outputs(rainbow) | ||
|
||
|
||
|
||
add_executable( | ||
nostalgia_prompt | ||
nostalgia_prompt.cpp | ||
) | ||
|
||
# Pull in pico libraries that we need | ||
target_link_libraries(nostalgia_prompt pico_stdlib hardware_pio hardware_adc hardware_dma pico_graphics galactic_unicorn) | ||
pico_enable_stdio_usb(nostalgia_prompt 1) | ||
|
||
# create map/bin/hex file etc. | ||
pico_add_extra_outputs(nostalgia_prompt) | ||
|
||
|
||
|
||
add_executable( | ||
eighties_super_computer | ||
eighties_super_computer.cpp | ||
) | ||
|
||
# Pull in pico libraries that we need | ||
target_link_libraries(eighties_super_computer pico_stdlib hardware_pio hardware_adc hardware_dma pico_graphics galactic_unicorn) | ||
pico_enable_stdio_usb(eighties_super_computer 1) | ||
|
||
# create map/bin/hex file etc. | ||
pico_add_extra_outputs(eighties_super_computer) | ||
|
||
|
||
|
||
|
||
add_executable( | ||
fire_effect | ||
fire_effect.cpp | ||
) | ||
|
||
# Pull in pico libraries that we need | ||
target_link_libraries(fire_effect pico_stdlib hardware_pio hardware_adc hardware_dma pico_graphics galactic_unicorn) | ||
pico_enable_stdio_usb(fire_effect 1) | ||
|
||
# create map/bin/hex file etc. | ||
pico_add_extra_outputs(fire_effect) | ||
|
||
|
||
|
||
|
||
add_executable( | ||
scroll_text | ||
scroll_text.cpp | ||
) | ||
|
||
# Pull in pico libraries that we need | ||
target_link_libraries(scroll_text pico_stdlib hardware_pio hardware_adc hardware_dma pico_graphics galactic_unicorn) | ||
pico_enable_stdio_usb(scroll_text 1) | ||
|
||
# create map/bin/hex file etc. | ||
pico_add_extra_outputs(scroll_text) | ||
|
||
|
||
add_executable( | ||
balls | ||
balls.cpp | ||
) | ||
|
||
# Pull in pico libraries that we need | ||
target_link_libraries(balls pico_stdlib hardware_pio hardware_adc hardware_dma pico_graphics galactic_unicorn) | ||
pico_enable_stdio_usb(balls 1) | ||
|
||
# create map/bin/hex file etc. | ||
pico_add_extra_outputs(balls) | ||
|
||
|
||
|
||
add_executable( | ||
lava_lamp | ||
lava_lamp.cpp | ||
) | ||
|
||
# Pull in pico libraries that we need | ||
target_link_libraries(lava_lamp pico_stdlib hardware_pio hardware_adc hardware_dma pico_graphics galactic_unicorn) | ||
pico_enable_stdio_usb(lava_lamp 1) | ||
|
||
# create map/bin/hex file etc. | ||
pico_add_extra_outputs(lava_lamp) | ||
|
||
|
||
|
||
add_executable( | ||
feature_test | ||
feature_test.cpp | ||
audio_samples.cpp | ||
) | ||
|
||
# Pull in pico libraries that we need | ||
target_link_libraries(feature_test pico_stdlib hardware_pio hardware_adc hardware_dma pico_graphics galactic_unicorn) | ||
pico_enable_stdio_usb(feature_test 1) | ||
|
||
# create map/bin/hex file etc. | ||
pico_add_extra_outputs(feature_test) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <math.h> | ||
#include "pico/stdlib.h" | ||
|
||
#include "libraries/pico_graphics/pico_graphics.hpp" | ||
#include "galactic_unicorn.hpp" | ||
#include "okcolor.hpp" | ||
|
||
using namespace pimoroni; | ||
|
||
PicoGraphics_PenRGB888 graphics(53, 11, nullptr); | ||
GalacticUnicorn galactic_unicorn; | ||
|
||
// extra row of pixels for sourcing flames and averaging | ||
float heat[53][13] = {0.0f}; | ||
|
||
int main() { | ||
|
||
stdio_init_all(); | ||
|
||
galactic_unicorn.init(); | ||
|
||
while(true) { | ||
if(galactic_unicorn.is_pressed(galactic_unicorn.SWITCH_BRIGHTNESS_UP)) { | ||
galactic_unicorn.adjust_brightness(+0.01); | ||
} | ||
if(galactic_unicorn.is_pressed(galactic_unicorn.SWITCH_BRIGHTNESS_DOWN)) { | ||
galactic_unicorn.adjust_brightness(-0.01); | ||
} | ||
|
||
graphics.set_pen(0, 0, 0); | ||
graphics.clear(); | ||
|
||
for(int y = 0; y < 12; y++) { | ||
for(int x = 0; x < 53; x++) { | ||
if(heat[x][y] > 0.5f) { | ||
graphics.set_pen(255, 255, 180); | ||
graphics.pixel(Point(x, y)); | ||
}else if(heat[x][y] > 0.4f) { | ||
graphics.set_pen(220, 160, 0); | ||
graphics.pixel(Point(x, y)); | ||
}else if(heat[x][y] > 0.3f) { | ||
graphics.set_pen(180, 50, 0); | ||
graphics.pixel(Point(x, y)); | ||
}else if(heat[x][y] > 0.2f) { | ||
graphics.set_pen(40, 40, 40); | ||
graphics.pixel(Point(x, y)); | ||
} | ||
|
||
// update this pixel by averaging the below pixels | ||
if(x == 0) { | ||
heat[x][y] = (heat[x][y] + heat[x][y + 2] + heat[x][y + 1] + heat[x + 1][y + 1]) / 4.0f; | ||
} else if(x == 52) { | ||
heat[x][y] = (heat[x][y] + heat[x][y + 2] + heat[x][y + 1] + heat[x - 1][y + 1]) / 4.0f; | ||
} else { | ||
heat[x][y] = (heat[x][y] + heat[x][y + 2] + heat[x][y + 1] + heat[x - 1][y + 1] + heat[x + 1][y + 1]) / 5.0f; | ||
} | ||
|
||
heat[x][y] -= 0.01f; | ||
heat[x][y] = heat[x][y] < 0.0f ? 0.0f: heat[x][y]; | ||
} | ||
} | ||
|
||
galactic_unicorn.update(&graphics); | ||
|
||
// clear the bottom row and then add a new fire seed to it | ||
for(int x = 0; x < 53; x++) { | ||
heat[x][11] = 0.0f; | ||
} | ||
|
||
// add a new random heat source | ||
for(int c = 0; c < 5; c++) { | ||
int px = (rand() % 51) + 1; | ||
heat[px][11] = 1.0f; | ||
heat[px + 1][11] = 1.0f; | ||
heat[px - 1][11] = 1.0f; | ||
heat[px][12] = 1.0f; | ||
heat[px + 1][12] = 1.0f; | ||
heat[px - 1][12] = 1.0f; | ||
} | ||
|
||
sleep_ms(50); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <math.h> | ||
#include "pico/stdlib.h" | ||
|
||
#include "libraries/pico_graphics/pico_graphics.hpp" | ||
#include "galactic_unicorn.hpp" | ||
#include "okcolor.hpp" | ||
|
||
using namespace pimoroni; | ||
|
||
PicoGraphics_PenRGB888 graphics(53, 11, nullptr); | ||
GalacticUnicorn galactic_unicorn; | ||
|
||
float lifetime[53][11]; | ||
float age[53][11]; | ||
|
||
int main() { | ||
|
||
stdio_init_all(); | ||
|
||
for(int y = 0; y < 11; y++) { | ||
for(int x = 0; x < 53; x++) { | ||
lifetime[x][y] = 1.0f + ((rand() % 10) / 100.0f); | ||
age[x][y] = ((rand() % 100) / 100.0f) * lifetime[x][y]; | ||
} | ||
} | ||
|
||
galactic_unicorn.init(); | ||
|
||
while(true) { | ||
if(galactic_unicorn.is_pressed(galactic_unicorn.SWITCH_BRIGHTNESS_UP)) { | ||
galactic_unicorn.adjust_brightness(+0.01); | ||
} | ||
if(galactic_unicorn.is_pressed(galactic_unicorn.SWITCH_BRIGHTNESS_DOWN)) { | ||
galactic_unicorn.adjust_brightness(-0.01); | ||
} | ||
|
||
graphics.set_pen(0, 0, 0); | ||
graphics.clear(); | ||
|
||
for(int y = 0; y < 11; y++) { | ||
for(int x = 0; x < 53; x++) { | ||
if(age[x][y] < lifetime[x][y] * 0.3f) { | ||
graphics.set_pen(230, 150, 0); | ||
graphics.pixel(Point(x, y)); | ||
}else if(age[x][y] < lifetime[x][y] * 0.5f) { | ||
float decay = (lifetime[x][y] * 0.5f - age[x][y]) * 5.0f; | ||
graphics.set_pen(decay * 230, decay * 150, 0); | ||
graphics.pixel(Point(x, y)); | ||
} | ||
|
||
if(age[x][y] >= lifetime[x][y]) { | ||
age[x][y] = 0.0f; | ||
lifetime[x][y] = 1.0f + ((rand() % 10) / 100.0f); | ||
} | ||
|
||
age[x][y] += 0.01f; | ||
} | ||
} | ||
|
||
galactic_unicorn.update(&graphics); | ||
|
||
sleep_ms(10); | ||
} | ||
|
||
return 0; | ||
} |
Oops, something went wrong.