Skip to content

Instantly share code, notes, and snippets.

//! Testing PWM output
//#![deny(unsafe_code)]
//#![deny(warnings)]
#![no_main]
#![no_std]
extern crate panic_halt;
use cast::{u16, u32};
//! Draw a 1 bit per pixel black and white image. On a 128x64 SSD1306 display over I2C.
//!
//! Image was created with ImageMagick:
//!
//! ```bash
//! convert rust.png -depth 1 gray:rust.raw
//! ```
//!
//! This example is for the STM32F103 "Blue Pill" board using I2C1.
//!
OLM_BASE_DIR = '/home/dev/git/olm'
MY_DEVICE_ID = 'MY_MATRIX_PYTHON_SDK_DEVICE'
MY_USER_ID = '@ray_test:matrix.org'
MY_PASSWORD = '...'
HOMIE_USER_ID = '@dhole:matrix.org'
HOMESERVER = 'https://matrix.org'
import os
import sys
#! /bin/sh
#set -e
set -x
reset_all () {
iptables -F
iptables -Z
ufw disable
iptables -X

Keybase proof

I hereby claim:

  • I am dhole on github.
  • I am dhole (https://keybase.io/dhole) on keybase.
  • I have a public key whose fingerprint is 9BC4 8EF8 08DB 91DD 158D 559D 4FA4 57A1 8514 CC63

To claim this, I am signing this object:

@Dhole
Dhole / sieve.rs
Last active May 18, 2016 14:13
Rust sieve
fn main() {
println!("{:?}", sieve1(30));
}
pub fn sieve1(n: u32) -> Vec<u32> {
let mut nums = (0..n).map(|x| Some(x)).collect::<Vec<Option<u32>>>();
let nums_len = nums.len() as u32;
for i in 2..nums.len() {
if let Some(y) = nums[i] {
for j in (2..).map(|x| x * y).take_while(|&j| j < nums_len) {
@Dhole
Dhole / stm32f4xx_it.c
Created December 25, 2014 00:52
custom logo
/* Read cartridge operation for MBC1 */
inline uint8_t mbc1_read(uint16_t addr) {
if (addr < 0x4000) {
/* 16KB ROM bank 00 */
if (no_show_logo) {
/* Custom logo disabled */
return rom_gb[addr];
} else {
/* Custom logo enabled, only during first read at boot */
if (addr == 0x133) {
/* Write cartridge operation for MBC1 */
inline void mbc1_write(uint16_t addr, uint8_t data) {
if (addr >= 0xA000 && addr < 0xC000) {
/* 8KB RAM Bank 00-03, if any */
ram[addr - 0xA000 + 0x2000 * ram_bank] = data;
}
/*if (addr < 0x2000) {
if (data) {
ram_enable = 1;
} else {
@Dhole
Dhole / stm32f4xx_it.c
Created December 24, 2014 23:36
MBC1 read
/* Read cartridge operation for MBC1 */
inline uint8_t mbc1_read(uint16_t addr) {
if (addr < 0x4000) {
/* 16KB ROM bank 00 */
return rom_gb[addr];
} else if (addr < 0x8000) {
/* 16KB ROM Bank 01-7F */
return rom_gb[addr + 0x4000 * (rom_bank - 1)];
} else if (addr >= 0xA000 && addr < 0xC000) {
/* 8KB RAM Bank 00-03, if any */
@Dhole
Dhole / stm32f4xx_it.c
Last active August 29, 2015 14:12
void EXTI0_IRQHandler(void)
#define BUS_RD (GPIOC->IDR & 0x0002)
#define BUS_WR (GPIOC->IDR & 0x0004)
#define ADDR_IN GPIOD->IDR
#define DATA_IN GPIOE->IDR
#define DATA_OUT GPIOE->ODR
#define SET_DATA_MODE_IN GPIOE->MODER = 0x00000000;
#define SET_DATA_MODE_OUT GPIOE->MODER = 0x55550000;
/* Handle PC0 interrupt (rising edge of the gameboy CLK) */
void EXTI0_IRQHandler(void) {