-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a289612
commit cdee90d
Showing
10 changed files
with
179 additions
and
227 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,4 +41,5 @@ node_modules | |
# Ignore files related to API keys | ||
.env | ||
|
||
build | ||
build | ||
.project |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* BlinkWorker.cpp | ||
* | ||
* Blink worker, to blink LED on a GPIO pad but do a random amount of work | ||
* between blinks | ||
* | ||
* Created on: 17 Aug 2022 | ||
* Author: jondurrant | ||
*/ | ||
|
||
#include "BlinkWorker.h" | ||
#include "math.h" | ||
#include <cstdio> | ||
|
||
//Blink Delay | ||
#define DELAY 500 | ||
|
||
/*** | ||
* Constructor | ||
* @param gp = GPIO pad number | ||
*/ | ||
BlinkWorker::BlinkWorker(uint8_t gp):BlinkAgent(gp) { | ||
//NOP | ||
|
||
} | ||
|
||
/*** | ||
* Destructor | ||
*/ | ||
BlinkWorker::~BlinkWorker() { | ||
// NOP | ||
} | ||
|
||
/*** | ||
* Main Run Task for agent | ||
*/ | ||
void BlinkWorker::run(){ | ||
|
||
printf("Blink Started\n"); | ||
|
||
gpio_init(xLedPad); | ||
|
||
gpio_set_dir(xLedPad, GPIO_OUT); | ||
|
||
while (true) { // Loop forever | ||
gpio_put(xLedPad, 1); | ||
vTaskDelay(DELAY); | ||
gpio_put(xLedPad, 0); | ||
|
||
int n = rand() % 5000; | ||
for (int i=0; i < n; i++ ){ | ||
double d = asin(sin(sqrt((double)n))); | ||
d = acos(cos(d)); | ||
} | ||
vTaskDelay(DELAY); | ||
if (pPeer != NULL){ | ||
xTaskNotifyGive(pPeer->getTask()); | ||
} | ||
uint32_t r = ulTaskNotifyTake(pdTRUE, DELAY); | ||
} | ||
|
||
} | ||
|
||
/*** | ||
* Get the static depth required in words | ||
* @return - words | ||
*/ | ||
configSTACK_DEPTH_TYPE BlinkWorker::getMaxStackSize(){ | ||
return 150; | ||
} | ||
|
||
|
||
/*** | ||
* Set Peer Worker | ||
* @param peer - peer BlinkWorker that we will sync blink with | ||
*/ | ||
void BlinkWorker::setPeer(BlinkWorker *peer){ | ||
pPeer = peer; | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* BlinkWorker.h | ||
* | ||
* Blink worker, to blink LED on a GPIO pad but do a random amount of work | ||
* between blinks | ||
* | ||
* Created on: 17 Aug 2022 | ||
* Author: jondurrant | ||
*/ | ||
|
||
#ifndef BLINKWORKER_H_ | ||
#define BLINKWORKER_H_ | ||
|
||
#include "pico/stdlib.h" | ||
#include <stdlib.h> | ||
#include "FreeRTOS.h" | ||
#include "task.h" | ||
|
||
#include "BlinkAgent.h" | ||
|
||
|
||
class BlinkWorker: public BlinkAgent { | ||
public: | ||
/*** | ||
* Constructor | ||
* @param gp = GPIO pad number | ||
*/ | ||
BlinkWorker(uint8_t gp); | ||
|
||
/*** | ||
* Destructor | ||
*/ | ||
virtual ~BlinkWorker(); | ||
|
||
/*** | ||
* Set Peer Worker | ||
* @param peer - peer BlinkWorker that we will sync blink with | ||
*/ | ||
virtual void setPeer(BlinkWorker *peer); | ||
|
||
|
||
protected: | ||
|
||
/*** | ||
* Run loop for the agent. | ||
*/ | ||
virtual void run(); | ||
|
||
|
||
/*** | ||
* Get the static depth required in words | ||
* @return - words | ||
*/ | ||
virtual configSTACK_DEPTH_TYPE getMaxStackSize(); | ||
|
||
|
||
BlinkWorker *pPeer = NULL; | ||
|
||
}; | ||
|
||
|
||
#endif /* BLINKWORKER_H_ */ |
This file contains 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.