Skip to content

Instantly share code, notes, and snippets.

View jamwaffles's full-sized avatar
💼
Hireable - Rust full time or part time

James Waples jamwaffles

💼
Hireable - Rust full time or part time
View GitHub Profile
@jamwaffles
jamwaffles / monotonic.rs
Created September 13, 2021 08:20
32 bit monotonic from STM32Lxx 16 bit timer
use core::convert::TryFrom;
use embedded_time::rate::{Extensions, Hertz};
use rtic::{rtic_monotonic::Clock, Monotonic};
use stm32l0xx_hal::{
pac::{TIM2, TIM21, TIM22, TIM3},
rcc::Rcc,
};
pub trait TimExt {
fn configure(&mut self, rcc: &mut Rcc, frequency: Hertz);
@jamwaffles
jamwaffles / monotonic.rs
Created May 10, 2021 09:26
L0xx monotonic impl for TIM2
use rtic::{rtic_monotonic::Clock, Monotonic};
use stm32l0xx_hal::pac::TIM2;
pub struct Tim2Monotonic {
local_timer: TIM2,
overflows: u16,
next_compare_value: Option<u32>,
}
impl Tim2Monotonic {
@jamwaffles
jamwaffles / docker-compose.yml
Created December 6, 2020 22:03
Grafana + Postgres
version: "3"
services:
adminer:
image: adminer:4.7.7
ports:
- "8081:8080"
networks:
- bbench
postgres:
linux_steps: &linux_steps
docker:
- image: cimg/rust:1.47.0
steps:
- checkout
- restore_cache:
keys:
- v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "Cargo.lock" }}
- run: ./linux_build_script_1_here.sh
- run: ./linux_build_script_2_here.sh
#![no_std]
#![no_main]
use panic_semihosting as _;
use rtfm::app;
use stm32f1xx_hal::{
device, gpio,
gpio::{gpioc::PC13, Edge, ExtiPin, Output, PushPull, State},
prelude::*,
stm32,
//! Interface factory
//!
//! This is the easiest way to create a driver instance. You can set various parameters of the
//! driver and give it an interface to use. The builder will return a
//! [`mode::RawMode`](../mode/raw/struct.RawMode.html) object which you should coerce to a richer
//! display mode, like [mode::Graphics](../mode/graphics/struct.GraphicsMode.html) for drawing
//! primitives and text.
//!
//! # Examples
//!
/* Copyright (c) 2015 Gordon Williams, Pur3 Ltd. Modified by James Waples 2018 */
/*
Library for interfacing to the EspressIF ESP8266. Uses the 'NetworkJS'
library to provide a JS endpoint for HTTP.
For EspressIF ESP8266 firmware 0.25
*/
var at;
var socks = [];
SPI1.setup({ baud:3200000, mosi: A7 });
var brightness = 0;
var delta = 1;
var maxBrightness = 250;
var numLeds = 12;
var data = new Uint8ClampedArray(numLeds * 3);
function sendFrame(data) {
@jamwaffles
jamwaffles / class.rs
Created August 13, 2015 19:51
Rust "class" definition
struct Sprite {
image_data: SomeBinaryType,
width: i16,
height: i16
}
impl Sprite {
pub fn new(filename: str) -> Sprite {
// TOOD: Load image into a Piston/OpenGL texture
var s3 = require('gulp-s3');
var gzip = require('gulp-gzip')
gulp.task('s3-gzip', function() {
var assetsConf = {
key: "YOURAWSKEYHERE",
secret: "sTuPiDLongS3CretKey",
region: 'eu-west-1',
bucket: 'bucketName'
}