Skip to content

Instantly share code, notes, and snippets.

@Measter
Measter / iterators.txt
Last active February 27, 2021 10:21
Rust Vec Fill Test
S 100 0
A 1500 40000
A 4100 40000
A 14300 40000
E 23500 0
@Measter
Measter / acserver_plugin_protocol.rs
Created October 21, 2020 01:50
AC Server Plugin Server Protocol
use nom::{IResult, number::complete::*, error::ErrorKind};
use nom_derive::Nom;
use thiserror::Error;
use std::{time::Duration, convert::TryFrom};
pub(crate) enum AcsCommand {
RealtimePosInterval = 200,
GetCarInfo = 201,
SendChat = 202,
@Measter
Measter / main.rs
Last active October 19, 2020 10:57
// Because there's no kill like over-kill, right?
use std::{
collections::HashMap,
io::{BufRead, BufReader},
ffi::OsStr,
fs::File,
path::Path,
};
@Measter
Measter / Example.rs
Last active April 21, 2021 18:36
MMIO Abstraction Example
#![no_std]
#![no_main]
#![feature(lang_items)]
mod register;
use register::*;
#[lang = "eh_personality"]
extern fn eh_personality() {}
@Measter
Measter / abstraction_adventures.md
Created September 8, 2020 16:04
My Adventures in MMIO Abstraction

My Adventures in MMIO Abstraction

Some years ago, I came across a simple Roguelike on Reddit called coreRL. It's very simplistic; levels are just a box with two walls, only one enemy type with basic AI, no health or character attributes, and the only goal is to see how far you can get before you die. Having nothing better to do, I thought it'd be a fun little project to write a port for an Arduino Nano. The only inputs needed are the four movement keys, and the display can just be a basic SSD1306-driven 128x64 OLED panel.

I could, of course, do this in C++. The language is a known quantity for the ATmega328P that powers the Arduino Nano. The toolchain is mature, as are the abstractions for interacting with the onboard peripherals. There are also libraries

@Measter
Measter / make_tone.cpp
Created June 5, 2020 16:41
Tone Prototype
template <class TonePin>
void make_tone(int frequency) {
IO::DigitalOut<TonePin> tonePin;
typename TonePin::TimerChannel channel;
typename TonePin::TimerChannel::Timer timer;
using PrescaleModes = typename TonePin::TimerChannel::Timer::PrescaleModes;
using WaveformModes = typename TonePin::TimerChannel::Timer::WaveformModes;
PrescaleModes mode = PrescaleModes::Stopped;
int ocr = 0;
@Measter
Measter / arduino_io.cpp
Last active June 2, 2020 15:46
StrongIO Bench
#include <Arduino.h>
void setup() {
// LED pin will act as a bookend to the IO tests.
DDRB |= (1 << PB5); // Configure builtin LED pin for output.
__asm__ volatile ("nop");
PORTB |= (1 << PB5); // Set LED pin high.
volatile uint8_t digital_data;
#include <Arduino.h>
#include "strong_io.h"
IO::PWM<Pin::D3> output1;
IO::DigitalOut<Pin::D4> output2;
IO::DigitalIn<Pin::D2> input1;
IO::AnalogIn<Pin::A0> input2;
void setup() {
}