Skip to content

Instantly share code, notes, and snippets.

View nanase's full-sized avatar
🏄
Making.

Nanase nanase

🏄
Making.
View GitHub Profile
@nanase
nanase / bleScanTask.py
Last active November 24, 2024 15:46
M5AtomS3R -> BLE -> Python (FastAPI & Bleak) - [Fragmentary code] The first code that successfully retrieved the BLE Characteristic for me in Windows.
import asyncio
import logging
import logging.config
import uuid
from bleak import BleakClient, BleakScanner
from bleak.backends.characteristic import BleakGATTCharacteristic
from bleak.backends.device import BLEDevice
from uvicorn.config import LOGGING_CONFIG
@nanase
nanase / loop_slave.cpp
Created May 1, 2022 08:29
Communication between Raspberry Pi Pico (RP2040) and STM32F303K8 with UART
// STM32F303K8 (Slave)
#include "main.h"
#include "usart.h"
/*
RP2040 ---- STM32F303K8
UART0_TX GPIO16 ---\/--- PB6 UART1_TX
UART0_RX GPIO17 <--/\--> PB7 UART1_RX
@nanase
nanase / PA30_PA31_output.ino
Created April 29, 2020 13:35
Manipulating PA30 and PA31 pins on Seeeduino XIAO
void setup() {
// instead of pinMode(30, OUTPUT);
(&(PORT->Group[PORTA]))->PINCFG[30].reg = (uint8_t)(PORT_PINCFG_INEN);
(&(PORT->Group[PORTA]))->PINCFG[31].reg = (uint8_t)(PORT_PINCFG_INEN);
(&(PORT->Group[PORTA]))->DIRSET.reg = (1 << 30);
(&(PORT->Group[PORTA]))->DIRSET.reg = (1 << 31);
}
void loop() {
// instead of digitalWrite(30, HIGH);
@nanase
nanase / samd21_pwm_triangle.ino
Last active August 24, 2021 23:18
Triangle wave output by PWM on Seeeduino XIAO
// Code from: https://www.hackster.io/voske65/high-speed-pwm-on-arduino-atsamd21-859b06
/*
HIGH FREQ PWM SETUP FOR MKR1000 - SAMW25 = SAMD21 with some other pinning
MKR1000's pins than can be defined as TCC timer pins and their associated channel (WO[X])
unless stated otherwise the TCC timers are on peripheral F:
A0 - PA02 - None
@nanase
nanase / sine_wave.ino
Created April 27, 2020 14:12
Sine wave output on Seeeduino XIAO
#define MAX_VALUE ((1 << 10) - 1)
#define SIN_MAX (MAX_VALUE / 2.0)
void setup() {
DAC->CTRLA.bit.ENABLE = 0x01;
syncDAC();
}
double i = 0.0;
@nanase
nanase / SerialMeasure.ino
Created April 24, 2020 03:59
Arduinoでシリアル通信の転送速度を測定します。PCへの送信のみです。
// このスケッチは以下の投稿にあるものを改良したもの
// https://forum.arduino.cc/index.php?topic=575333.0
char text[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQR"
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQR"
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQR"
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQR";
void setup() {
Serial.begin(250000);
#include <SPI.h>
#define PIN_SCK 13
#define PIN_SDI 11
#define PIN_LATCH 10
#define SCROLL_SPEED 250
const byte digits[] PROGMEM = {
0b11111100, // 0
0b01100000, // 1
#include <SPI.h>
#define PIN_SCK 13
#define PIN_SDI 11
#define PIN_LATCH 10
#define SCROLL_SPEED 10
const byte digits[] PROGMEM = {
0b10000000, // 1
0b01000000, // 2
#include <SPI.h>
#define PIN_SCK 13
#define PIN_SDI 11
#define PIN_LATCH 10
#define SCROLL_SPEED 50
const byte digits[] PROGMEM = {
0b11111100, // 0
0b01100000, // 1
@nanase
nanase / aqm1602.cpp
Created January 15, 2020 23:40
AQM1602Y on Arduino MKR ZERO (experiments)
#include "aqm1602.h"
AQM1602::AQM1602(uint8_t i2cAddress, uint8_t voltage, uint8_t contrast) {
this->i2cAddress = i2cAddress;
this->contrast = contrast;
this->voltage = voltage;
this->displayControl = 0x00;
// ACM series = 0x80
// AQM series = 0x40