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

lab6 recording as

parent b40b8e49
#include "funshield.h"
#include "string.h"
// map of letter glyphs
constexpr byte LETTER_GLYPH[] {
0b10001000, // A
......@@ -29,4 +32,101 @@ constexpr byte LETTER_GLYPH[] {
};
constexpr byte EMPTY_GLYPH = 0b11111111;
constexpr int positionsCount = 4;
\ No newline at end of file
constexpr int positionsCount = 4;
constexpr unsigned int scrollingInterval = 300;
void displayChar(char ch, byte pos)
{
byte glyph;
if (isAlpha(ch)) {
glyph = LETTER_GLYPH[ ch - (isUpperCase(ch) ? 'A' : 'a') ];
}
else if (isDigit(ch)) {
glyph = digits[ch - '0'];
}
else {
glyph = EMPTY_GLYPH;
}
digitalWrite(latch_pin, LOW);
shiftOut(data_pin, clock_pin, MSBFIRST, glyph);
shiftOut(data_pin, clock_pin, MSBFIRST, 1 << pos);
digitalWrite(latch_pin, HIGH);
}
const char* message = "Ahoj";
class Display
{
public:
void loop()
{
int message_len = strlen(message);
char c = pozicia_ < message_len ? message[pozicia_] : ' ';
displayChar(c, pozicia_);
pozicia_++;
pozicia_ %= 4;
}
private:
int pozicia_ = 0;
};
void setup() {
pinMode(latch_pin, OUTPUT);
pinMode(clock_pin, OUTPUT);
pinMode(data_pin, OUTPUT);
}
Display d;
void loop() {
d.loop();
}
///////////////////////////////////////////POINTER & ARRAY///////////////////////////////////////
#include <stdio.h>
#include <string.h>
constexpr char* str_ptr = "Ahoj";
// A | h | o | j | '\0'
// ^ | ^
//str_ptr|str_ptr+1
const char str_arr[5] {'A', 'h', 'o', 'j', '\0'};
const size_t size_arr = sizeof(str_arr); // 5 -> 5 prvkov velkosti 1B
const size_t size_ptr = sizeof(str_ptr); // 8 -> velkost adresy na ktoru pointer ukazuje
const char c1 = *str_ptr; // 'A'
const char c2 = str_arr[0]; // 'A'
const char c3 = *(str_ptr + 1); // 'h'
const char c4 = str_ptr[1]; // 'h'
int mystrlen(const char* s)
{
int i = 0;
while(*s++) ++i;
return i;
}
const char* str1 = "Ahoj1";
const char* str2 = "Ahoj2123";
int main()
{
str1 = str2; // str1 ukazuje teraz na rovnake miesto v pamati ako str2, teda na "Ahoj2123"
const char* str = str1;
int str_size = strlen(str);
int mystr_size = mystrlen(str);
printf("String size from strlen is %d\n", str_size);
printf("String size from mystrlen is %d\n", mystr_size);
}
\ No newline at end of file
......@@ -733,7 +733,7 @@ $(document).ready(function(){
<td class="right">26.5.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/abc5a087-e1b0-48c4-96d8-6bdd9a4a7f89">Recorded lecture</a></td>
</tr>
<tr>
<td class="right">1.6.2021</td>
......
Markdown is supported
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