Merge pull request #694 from pimoroni/patch-cosmic-paint
Cosmic Unicorn: Port paint example.
This commit is contained in:
commit
9c1c9e6b8d
|
@ -1,6 +1,6 @@
|
||||||
# Galactic Paint
|
# Cosmic Paint
|
||||||
|
|
||||||
Galactic Paint lets you paint pixels onto your Galatic Unicorn over WiFi, in realtime!
|
Cosmic Paint lets you paint pixels onto your Cosmic Unicorn over WiFi, in realtime!
|
||||||
|
|
||||||
## Setting Up
|
## Setting Up
|
||||||
|
|
|
@ -2,15 +2,15 @@ import os
|
||||||
from microdot_asyncio import Microdot, send_file
|
from microdot_asyncio import Microdot, send_file
|
||||||
from microdot_asyncio_websocket import with_websocket
|
from microdot_asyncio_websocket import with_websocket
|
||||||
from phew import connect_to_wifi
|
from phew import connect_to_wifi
|
||||||
from galactic import GalacticUnicorn
|
from cosmic import CosmicUnicorn
|
||||||
from picographics import PicoGraphics, DISPLAY_GALACTIC_UNICORN as DISPLAY
|
from picographics import PicoGraphics, DISPLAY_COSMIC_UNICORN as DISPLAY
|
||||||
from WIFI_CONFIG import SSID, PSK
|
from WIFI_CONFIG import SSID, PSK
|
||||||
|
|
||||||
|
|
||||||
gu = GalacticUnicorn()
|
cu = CosmicUnicorn()
|
||||||
graphics = PicoGraphics(DISPLAY)
|
graphics = PicoGraphics(DISPLAY)
|
||||||
mv_graphics = memoryview(graphics)
|
mv_graphics = memoryview(graphics)
|
||||||
gu.set_brightness(0.5)
|
cu.set_brightness(0.5)
|
||||||
|
|
||||||
WIDTH, HEIGHT = graphics.get_bounds()
|
WIDTH, HEIGHT = graphics.get_bounds()
|
||||||
|
|
||||||
|
@ -24,12 +24,12 @@ server = Microdot()
|
||||||
|
|
||||||
@server.route("/", methods=["GET"])
|
@server.route("/", methods=["GET"])
|
||||||
def route_index(request):
|
def route_index(request):
|
||||||
return send_file("galactic_paint/index.html")
|
return send_file("cosmic_paint/index.html")
|
||||||
|
|
||||||
|
|
||||||
@server.route("/static/<path:path>", methods=["GET"])
|
@server.route("/static/<path:path>", methods=["GET"])
|
||||||
def route_static(request, path):
|
def route_static(request, path):
|
||||||
return send_file(f"galactic_paint/static/{path}")
|
return send_file(f"cosmic_paint/static/{path}")
|
||||||
|
|
||||||
|
|
||||||
def get_pixel(x, y):
|
def get_pixel(x, y):
|
||||||
|
@ -86,7 +86,7 @@ async def echo(request, ws):
|
||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
if data == "show":
|
if data == "show":
|
||||||
gu.update(graphics)
|
cu.update(graphics)
|
||||||
|
|
||||||
if data == "fill":
|
if data == "fill":
|
||||||
data = await ws.receive()
|
data = await ws.receive()
|
|
@ -2,14 +2,14 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Galactic Paint</title>
|
<title>Cosmic Paint</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link href="//cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
|
<link href="//cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
|
||||||
<link rel="stylesheet" type="text/css" href="/static/paint.css">
|
<link rel="stylesheet" type="text/css" href="/static/paint.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="window">
|
<div class="window">
|
||||||
<h1>Galactic Paint</h1>
|
<h1>Cosmic Paint</h1>
|
||||||
<table cellspacing="0" cellpadding="0" border-collapse="collapse">
|
<table cellspacing="0" cellpadding="0" border-collapse="collapse">
|
||||||
<tbody></tbody>
|
<tbody></tbody>
|
||||||
</table>
|
</table>
|
|
@ -64,7 +64,7 @@ body {
|
||||||
}
|
}
|
||||||
|
|
||||||
.window {
|
.window {
|
||||||
width: 976px;
|
width: 640px;
|
||||||
position: relative;
|
position: relative;
|
||||||
background: #0E071A;
|
background: #0E071A;
|
||||||
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.5);
|
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.5);
|
|
@ -1,5 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var WIDTH = 32;
|
||||||
|
var HEIGHT = 32;
|
||||||
var md = false;
|
var md = false;
|
||||||
var color = tinycolor('#840000');
|
var color = tinycolor('#840000');
|
||||||
var update;
|
var update;
|
||||||
|
@ -20,9 +22,9 @@ $(document).ready(function(){
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
for (var y = 0; y < 11; y++) {
|
for (var y = 0; y < HEIGHT; y++) {
|
||||||
var row = $('<tr></tr>');
|
var row = $('<tr></tr>');
|
||||||
for (var x = 0; x < 53; x++) {
|
for (var x = 0; x < WIDTH; x++) {
|
||||||
row.append('<td></td>');
|
row.append('<td></td>');
|
||||||
}
|
}
|
||||||
$('tbody').append(row);
|
$('tbody').append(row);
|
Loading…
Reference in New Issue