Skip to content

Instantly share code, notes, and snippets.

@electronut
electronut / desktop.md
Last active May 18, 2018
Electronut Labs economical Desktop PC configuration
View desktop.md
View 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
View 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
View stm32-conway-signal.cpp
void Conway64::signal()
{
osSignalSet (_conwayTaskHandle, 0x0001);
}
View 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
View 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
View 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 Oct 29, 2017
stm32-returns-5.c
View 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;
View stm32-returns-4.c
struct BitBuf88
{
// constr
BitBuf88() {
clearAll();
}
// destr
virtual ~BitBuf88() {}
// set (i, j)
View 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);
You can’t perform that action at this time.