GY-63_MS5611/libraries/Adler/Adler32.h

59 lines
1.1 KiB
C
Raw Normal View History

2022-06-16 03:46:28 -04:00
#pragma once
//
// FILE: Adler.h
// AUTHOR: Rob Tillaart
2023-01-16 10:33:37 -05:00
// VERSION: 0.2.3
2022-06-16 03:46:28 -04:00
// DATE: 2022-01-27
// PURPOSE: Arduino Library for calculating Adler-32 checksum
// URL: https://github.com/RobTillaart/Adler
// https://en.wikipedia.org/wiki/Adler-32
#include "Arduino.h"
2023-01-16 10:33:37 -05:00
#define ADLER32_LIB_VERSION (F("0.2.3"))
2022-06-16 03:46:28 -04:00
// largest prime below 2^16
const uint32_t ADLER32_MOD_PRIME = 65521;
class Adler32
{
public:
Adler32();
2022-09-21 03:34:38 -04:00
void begin(uint32_t s1 = 1, uint32_t s2 = 0);
2022-06-16 03:46:28 -04:00
2023-01-16 10:33:37 -05:00
2022-09-21 03:34:38 -04:00
void add(uint8_t value);
// returns current Adler value
uint32_t add(uint8_t * array, uint16_t length);
2022-06-16 03:46:28 -04:00
// trade PROGMEM for speed
2022-09-21 03:34:38 -04:00
// returns current Adler value
uint32_t addFast(uint8_t * array, uint16_t length);
2022-06-16 03:46:28 -04:00
2023-01-16 10:33:37 -05:00
2022-06-16 03:46:28 -04:00
// wrappers for strings
2022-09-21 03:34:38 -04:00
void add(char value);
// returns current Adler value
uint32_t add(char * array, uint16_t length);
// returns current Adler value
uint32_t addFast(char * array, uint16_t length);
2022-06-16 03:46:28 -04:00
uint32_t getAdler();
2022-09-21 03:34:38 -04:00
uint32_t count();
2022-06-16 03:46:28 -04:00
2023-01-16 10:33:37 -05:00
2022-06-16 03:46:28 -04:00
private:
uint32_t _s1;
uint32_t _s2;
uint32_t _count;
};
2023-01-16 10:33:37 -05:00
// -- END OF FILE --
2022-06-16 03:46:28 -04:00