Commit 83f93e49 authored by Šmelko Adam Mgr.'s avatar Šmelko Adam Mgr.
Browse files

Add lab recording link.

parent 2729c944
......@@ -45,70 +45,63 @@ void setup() {
}
}
class LedState
enum LedState {PRESSED, RELEASED};
class LedSwitcher
{
public:
enum InnerStates { BEING_PRESSED, NOT_BEEING_PRESSED };
LedState(int pin) {
LedSwitcher(int pin) {
pin_ = pin;
}
void react(bool buttonPressed)
void switchOnOff(bool button_pressed)
{
if (!buttonPressed) {
state_ = NOT_BEEING_PRESSED;
if (button_pressed == false) {
prev_state_ = RELEASED;
return;
}
if (buttonPressed && state_ == BEING_PRESSED)
if (prev_state_ == PRESSED && button_pressed)
return;
state_ = BEING_PRESSED;
prev_state_ = PRESSED;
is_on_ = !is_on_;
digitalWrite(pin_, is_on_ ? ON : OFF);
}
private:
bool is_on_ = false;
InnerStates state_ = NOT_BEEING_PRESSED;
LedState prev_state_ = RELEASED;
int pin_;
};
LedState ledStates[] { LedState(led1_pin), LedState(led2_pin), LedState(led3_pin) };
LedSwitcher switchers[] { LedSwitcher(led1_pin), LedSwitcher(led2_pin), LedSwitcher(led3_pin) };
void loop() {
// put your main code here, to run repeatedly:
for (int i = 0; i < buttonCount; i++) {
bool pressed = !digitalRead(buttons[i]);
ledStates[i].react(pressed);
switchers[i].switchOnOff(pressed);
}
}
//////////////REFERENCE/////////////////
#include <iostream>
class Test
class X
{
public:
int x = 1;
void zdvihniCitac(int& citac) // <<<<< aha ampersand
{
citac++;
}
};
void fNOREF(Test test)
{
test.x = 2;
}
void fREF(Test& test)
{
test.x = 2;
}
int main()
{
Test test;
test.x = 8;
fNOREF(test);
std::cout << "Test::x is: "<<test.x << std::endl; // prints 8!!!!!
fREF(test);
std::cout << "Test::x is: "<<test.x << std::endl; // prints 2!!!!!
X object;
int citac = 4;
object.zdvihniCitac(citac);
std::cout << citac << std::endl; // citac sa zdvihne len ked je pri parametri metody & !!!
}
\ No newline at end of file
......@@ -624,7 +624,7 @@ $(document).ready(function(){
<td class="right">7.4.2021</td>
<td>934 5196 8778</td>
<td><a class="extern" href="https://cesnet.zoom.us/j/93451968778">Join the lab - Šmelko</a></td>
<td>Recorded lab</td>
<td><a class="extern" href="https://web.microsoftstream.com/video/63d2b687-f5dd-49d1-a82f-6361c01df730">Recorded lab</a></td>
</tr>
<tr>
<td class="right">13.4.2021</td>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment