Skip to content

Instantly share code, notes, and snippets.

View xeecos's full-sized avatar

xeecos xeecos

View GitHub Profile
@xeecos
xeecos / rendersvg.js
Last active October 10, 2023 02:53
render svg using nanosvg.js
import {parse as parseSVG} from "./nanosvg.js"
let svg = fs.readFileSync(svg_url).toString();
let res = parseSVG(svg,"mm",72);
let canvas = document.getElementById("canvas");
let ctx = canvas.getContext("2d");
for (let shape = shapes; shape != null; shape = shape.next) {
if(shape.fill.type==1)
{
let color = shape.fill.color;
let r = Number(color&0xff);
@xeecos
xeecos / main.cpp
Last active March 8, 2023 08:55
jpeg encode test @https://github.com/espressif/esp-adf-libs/tree/master/esp_codec
#include <Arduino.h>
#include "esp_jpeg_enc.h"
int esp_jpeg_enc_demo1()
{
/// configure encoder
jpeg_enc_info_t info = DEFAULT_JPEG_ENC_CONFIG();
info.quality = 80;
info.src_type = JPEG_RAW_TYPE_RGB888;
/// allocate input buffer to fill original image stream.
@xeecos
xeecos / lz4.sh
Created February 22, 2023 08:42
ubuntu 18.04 install lz4
sudo apt-get install liblz4-tool
@xeecos
xeecos / esp32-s3-wroom-1.json
Created February 7, 2023 01:03
platformio add esp32-s3-wroom-1 board
{
"build": {
"arduino":{
"ldscript": "esp32s3_out.ld",
"partitions": "default_8MB.csv",
"memory_type": "qio_opi"
},
"core": "esp32",
"extra_flags": [
"-DARDUINO_ESP32S3_DEV",
@xeecos
xeecos / potrace.js
Created January 31, 2023 02:34
add stroke support
'use strict';
var Jimp = require('jimp');
var Bitmap = require('./types/Bitmap');
var Curve = require('./types/Curve');
var Point = require('./types/Point');
var Path = require('./types/Path');
var Quad = require('./types/Quad');
var Sum = require('./types/Sum');
var Opti = require('./types/Opti');
@xeecos
xeecos / binding.cc
Last active January 6, 2023 03:04
node-gyp example
#include <node.h>
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::String;
using v8::Value;
void Method(const FunctionCallbackInfo<Value> &args)
#include <Arduino.h>
#include <HWCDC.h>
#include "math.h"
#include "SPI.h"
HWCDC USBSerial;
SPIClass spi = SPIClass(FSPI);
#include "SdFat.h"
#include "math.h"
#include "FS.h"
#include "SD_MMC.h"
void testFileIO(fs::FS &fs, const char *path, uint32_t buffSize, uint32_t numMB)
{
uint8_t *buff = (uint8_t *)ps_malloc(buffSize);
File file = fs.open(path, FILE_WRITE);
if (file)
@xeecos
xeecos / change_to_host.sh
Created November 10, 2022 06:40
set allwinner f1c200s usb host mode
echo host > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
let buf = [];
let binhex = u8g2.getBufferPtr();
while (y < height) {
let ym = 1 << (y % 8); // Bitmask
let bp = width * (y >> 3); // Start pointer of the row
let x = 0;
while (x < width) {
let d = 0;
if (binhex[bp+7] & ym) d |= 0x80;
if (binhex[bp+6] & ym) d |= 0x40;