Skip to content

Instantly share code, notes, and snippets.

@electronut
electronut / desktop.md
Last active December 3, 2019 10:53
Electronut Labs economical Desktop PC configuration
@electronut
electronut / lorenz1.py
Created November 24, 2017 14:29
lorenz1.py
# parameters
P = 10
A = 28
B = 8.0/3.0
dt = 0.01
# initial conditions
x = 1.0
y = 1.0
z = 1.0
self.scale = 5
@electronut
electronut / stm32-conway-update.cpp
Created October 29, 2017 08:39
stm32-conway-update.cpp
void Conway64::update()
{
// From my book Python Playground
// https://www.nostarch.com/pythonplayground
// copy grid since we require 8 neighbors for calculation
// and we go line by line
BitBuf88 _newGrid = _grid;
uint8_t N = 8;
// compute 8-neighbour sum
@electronut
electronut / stm32-conway-signal.cpp
Created October 29, 2017 08:39
stm32-conway-signal.cpp
void Conway64::signal()
{
osSignalSet (_conwayTaskHandle, 0x0001);
}
@electronut
electronut / stm32-conway-task.cpp
Created October 29, 2017 08:32
stm32-conway-task.cpp
// The Conway Task function
void conwayTaskFunc(void const * arg)
{
// The Joy of C++
Conway64* conway = const_cast<Conway64*>(static_cast<const Conway64*>(arg));
// enable for testing only
//conway->testInit();
// add a glider object
@electronut
electronut / stm32-conway-init.cpp
Created October 29, 2017 08:30
stm32-conway-init.cpp
// initialize
void Conway64::init()
{
// set up display
_max7219->power(true);
_max7219->setIntensity(5);
_max7219->setScanLimit(7);
_max7219->clear();
// create Conway task
@electronut
electronut / stm32-conway.h
Created October 29, 2017 08:28
stm32-conway.h
class Conway64 {
public:
Conway64(SPI_HandleTypeDef* hSPI);
virtual ~Conway64();
// initialize
void init();
// add glider with top left cell at (i, j)
void addGlider(int i, int j);
@electronut
electronut / stm32-returns-5.c
Last active October 29, 2017 08:24
stm32-returns-5.c
// send 16 bit data packet
void MAX7219::sendPacket(MAX7129_REG reg, uint8_t data)
{
// CS
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_RESET);
//uint16_t packet = (reg << 8) | data;
uint8_t packet[2];
packet[0] = reg;
packet[1] = data;
@electronut
electronut / stm32-returns-4.c
Created October 29, 2017 08:17
stm32-returns-4.c
struct BitBuf88
{
// constr
BitBuf88() {
clearAll();
}
// destr
virtual ~BitBuf88() {}
// set (i, j)
@electronut
electronut / stm32-returns-3.c
Created October 29, 2017 08:07
stm32-returns-3.c
/* StartDefaultTask function */
void StartDefaultTask(void const * argument)
{
/* USER CODE BEGIN 5 */
/* Infinite loop */
for(;;)
{
HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);
osDelay(250);
HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);