Skip to content

Instantly share code, notes, and snippets.

Avatar

xeecos xeecos

View GitHub Profile
View ESP32-C3-SD_SPI-Speed-Test.ino
#include <Arduino.h>
#include <HWCDC.h>
#include "math.h"
#include "SPI.h"
HWCDC USBSerial;
SPIClass spi = SPIClass(FSPI);
#include "SdFat.h"
View ESP32-S3-SD_MMC-Speed-Test.ino
#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 Nov 10, 2022
set allwinner f1c200s usb host mode
View change_to_host.sh
echo host > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
View u8g2_to_pbm.js
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;
View sdfat.ino
#include "SdFat.h"
// SPI_DRIVER_SELECT == 0 // Must be set in SdFat/SdFatConfig.h
#define PIN_SD_CS 33
#define PIN_SD_MOSI 27
#define PIN_SD_MISO 25
#define PIN_SD_SCK 26
#define SD_FAT_TYPE 0
SPIClass spi(HSPI);
View bin2array.js
const fs = require("fs")
let buf = fs.readFileSync("file.bin");
let arr = [];
for(let i=0;i<buf.length;i++)
{
arr.push('0x'+buf[i].toString(16));
}
fs.writeFileSync("file.txt","["+arr.join(",")+"]")
@xeecos
xeecos / webview.py
Created Jan 10, 2022
mini webview client
View webview.py
import webview
webview.create_window('Stellarium-Web', 'https://stellarium-web.org/')
webview.start()
View rgbled.py
###USAGE###
# pip3 install makeblock --upgrade
###########
from time import sleep
from random import random
import math
from makeblock import MegaPi,SerialPort
A6 = 60
A7 = 61
A8 = 62
View sensor.py
###USAGE###
# pip3 install makeblock --upgrade
###########
from time import sleep
from makeblock import MegaPi,SerialPort
megapi = MegaPi.connect() # or megapi = MegaPi.connect(SerialPort.connect("/dev/ttyXXXX"))
A6 = 60
A7 = 61
A8 = 62
A9 = 63
View megapi.py
###USAGE###
# pip3 install makeblock
###########
from time import sleep
from makeblock import MegaPi,SerialPort
megapi = MegaPi.connect() # or megapi = MegaPi.connect(SerialPort.connect("/dev/ttyXXXX"))
motor1 = megapi.DCMotor(1,1)
motor2 = megapi.DCMotor(1,2)
motor3 = megapi.DCMotor(2,1)
motor4 = megapi.DCMotor(2,2)