Skip to content

Instantly share code, notes, and snippets.

@jon1012
jon1012 / awake0.jpg
Last active June 12, 2018 08:28
Child day/night monitor M5Stack
awake0.jpg
@jon1012
jon1012 / clock.py
Last active October 12, 2017 22:18
just a test to display a clock on m5stack using loboris esp32 stack
import machine, time
tft.init(tft.ILI9341, width=320, height=320, miso=19, mosi=23, clk=18, cs=14, dc=27, bgr=True, backl_pin=32, rst_pin=33, backl_on=1, spihost=tft.VSPI, invrot=2)
tft.orient(2)
tft.font(tft.FONT_7seg, color=tft.WHITE)
while True:
now = machine.RTC().now()
txt = "%02d:%02d:%02d" % now[3:6]
@jon1012
jon1012 / sds011.py
Last active October 23, 2017 09:23 — forked from geoffwatts/sds011.py
Read an SDS011 Laser PM2.5 Sensor (Nova PM Sensor) with Python
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import serial, time, struct
import httplib, urllib
ser = serial.Serial("/dev/ttyUSB0", baudrate=9600, stopbits=1, parity="N", timeout=2)
ser.flushInput()
def scale_to_fit(image, frame, enlarge=False):
image_width, image_height = image
frame_width, frame_height = frame
image_aspect = float(image_width) / image_height
frame_aspect = float(frame_width) / frame_height
# Determine maximum width/height (prevent up-scaling).
if not enlarge:
max_width = min(frame_width, image_width)
max_height = min(frame_height, image_height)
else:
@jon1012
jon1012 / Category.sql
Last active August 29, 2015 14:13 — forked from ticean/Category.sql
SET @entityid = '3';
SELECT ea.attribute_id, ea.attribute_code, eav.value AS 'value', 'varchar' AS 'type'
FROM catalog_category_entity e
JOIN catalog_category_entity_varchar eav
ON e.entity_id = eav.entity_id
JOIN eav_attribute ea
ON eav.attribute_id = ea.attribute_id
WHERE e.entity_id = @entityid
UNION
@jon1012
jon1012 / robot.js
Created December 6, 2012 19:05
Just Try :)
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
var should_rotate = true;
Robot.prototype.onIdle = function(ev) {
@jon1012
jon1012 / robot.js
Created December 6, 2012 17:17
Hackish Rubish
var cannon_rotate = 1;
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.back(10);
@jon1012
jon1012 / robot.js
Created December 6, 2012 17:06
Hacky Robbie
var locked = false;
var numlock = 0;
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
if (!locked) {