Skip to content

Instantly share code, notes, and snippets.

View phoddie's full-sized avatar

Peter Hoddie phoddie

View GitHub Profile
@phoddie
phoddie / easing.c
Created February 17, 2024 06:49
break out easing functions to module
/*
* Copyright (c) 2016-2024 Moddable Tech, Inc.
*
* This file is part of the Moddable SDK Runtime.
*
* The Moddable SDK Runtime is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
@phoddie
phoddie / network.c
Created February 23, 2022 00:13
shocking xsbug-over-wifi back to life for ESP32
#include "xsmc.h"
#include "xsHost.h"
extern void fxConnectTo(xsMachine *the, void *pcb);
extern void *modSocketGetLWIP(xsMachine *the, xsSlot *slot);
extern void espDescribeInstrumentation(xsMachine *the);
void xs_debug(xsMachine *the)
{
#ifdef mxDebug
@phoddie
phoddie / main.js
Last active February 9, 2022 00:14
Battery monitor for M5Paper
/*
* Copyright (c) 2016-2022 Moddable Tech, Inc.
*
* This file is part of the Moddable SDK.
*
* This work is licensed under the
* Creative Commons Attribution 4.0 International License.
* To view a copy of this license, visit
* <http://creativecommons.org/licenses/by/4.0>.
* or send a letter to Creative Commons, PO Box 1866,
@phoddie
phoddie / main.js
Created February 1, 2021 21:49
RMT implementation for ESP32
import RMT from "rmt";
let a = new RMT({pin: 2, channel: 0, divider: 255}); // GPIO 2, RMT channel 0, clk_div 255
a.onWritable = function() {
a.write(0, [32000 * 9, 32000, 32000 * 9, 32000, 32000 * 9, 32000, 32000 * 9, 32000]);
}
@phoddie
phoddie / main.js
Created January 18, 2021 22:57
Moddable SDK - UDP example
import {Socket} from "socket";
import Timer from "timer"
const socket = new Socket({kind: "UDP"});
socket.callback = function(message, value) {
if (Socket.readable !== message)
return;
const buffer = this.read(ArrayBuffer);
const longs = new Uint32Array(buffer);
@phoddie
phoddie / tasks.json
Last active January 6, 2022 02:06
For Visual Studio Code builds. Goes into .vscode directory.
{
"version": "2.0.0",
"tasks": [
{
"label": "Build ESP8266 Debug",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
@phoddie
phoddie / blue.js
Last active December 5, 2020 23:29
export default function() {
trace("blue\n");
}
@phoddie
phoddie / SPI.md
Created October 20, 2020 23:59
SPI Module for ESP8266 and ESP32

class SPI

The SPI class provides access to the SPI bus connected to Clock, MISO, and MOSI pins along with a designated Chip Select pin.

import SPI from "pins/spi";

constructor(dictionary)

The SPI constructor takes a dictionary which contains at least the frequency of the SPI device in Hertz (hz) and a sub-object (cs) containing the chip select pin number (pin).

@phoddie
phoddie / jpeg.js
Last active September 18, 2020 19:37
Uses Poco clipping too decompress and draw a JPEG image with text superimposed using no extra microcontroller memory needed.
let palatino36 = parseBMF(new Resource("palatino_36.fnt"));
palatino36.bitmap = parseBMP(new Resource("palatino_36.bmp"));
// background
poco.begin()
poco.fillRectangle(gray, 0, 0, poco.width, poco.height);
poco.drawText("Hello Basuke", palatino36, white, 15, 20);
poco.end();
// render JPEG blocks with text composed on top

Algorithms for TC53

Updated November 20, 2020

Notes

  • This document is an attempt to define formal algorithms for the draft of the TC53 specification
  • This document describes somee, but not all, of the APIs. Once these are in good shape, thy will be used as a model for the remaining APIs
  • The intent is to merge these algorithms into the specification

Internal Fields