Advertisement
FlyFar

data.h

Jul 17th, 2023
923
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 140.42 KB | Cybersecurity | 0 0
  1. #ifndef data_h
  2. #define data_h
  3.  
  4. const uint8_t data_error404[] PROGMEM = "<html><head><meta charset='utf-8'></head><body><h1>ERROR 404</h1><p>¯\\_(ツ)_/¯ </p></body></html>"" B";
  5.   else if(bytes < (1024 * 1024)) return String(bytes/1024.0)+" KB";
  6.   else if(bytes < (1024 * 1024 * 1024)) return String(bytes/1024.0/1024.0)+" MB";
  7.   else return String(bytes/1024.0/1024.0/1024.0)+" GB";
  8. }
  9.  
  10. //source: https://forum.arduino.cc/index.php?topic=38107.0
  11. void PrintHex8(uint8_t *data, uint8_t length){
  12.   Serial.print("0x");
  13.   for (int i=0; i<length; i++) {
  14.     if (data[i]<0x10) {Serial.print("0");}
  15.     Serial.print(data[i],HEX);
  16.     Serial.print(" ");
  17.   }
  18. }
  19.  
  20. //source: http://shelvin.de/eine-integer-zahl-in-das-arduiono-eeprom-schreiben/
  21. void eepromWriteInt(int adr, int val) {
  22.   byte low, high;
  23.   low = val & 0xFF;
  24.   high = (val >> 8) & 0xFF;
  25.   EEPROM.write(adr, low);
  26.   EEPROM.write(adr+1, high);
  27.   return;
  28. }
  29.  
  30. int eepromReadInt(int adr) {
  31.   byte low, high;
  32.   low = EEPROM.read(adr);
  33.   high = EEPROM.read(adr+1);
  34.   return low + ((high << 8) & 0xFF00);
  35. }
  36.  
  37. #endif
Tags: data
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement