This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Conway64 conway(&hspi2); | |
int main(void) | |
{ | |
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */ | |
HAL_Init(); | |
/* Configure the system clock */ | |
SystemClock_Config(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct BitBuf88 | |
{ | |
// constr | |
BitBuf88() { | |
clearAll(); | |
} | |
// destr | |
virtual ~BitBuf88() {} | |
// set (i, j) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initialize | |
void Conway64::init() | |
{ | |
// set up display | |
_max7219->power(true); | |
_max7219->setIntensity(5); | |
_max7219->setScanLimit(7); | |
_max7219->clear(); | |
// create Conway task |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Conway64::signal() | |
{ | |
osSignalSet (_conwayTaskHandle, 0x0001); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |