Skip to content

Commit 6af41f6

Browse files
committed
english readme
1 parent 157eb5c commit 6af41f6

File tree

1 file changed

+188
-172
lines changed

1 file changed

+188
-172
lines changed

README_EN.md

Lines changed: 188 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -1,201 +1,217 @@
11
This is an automatic translation, may be incorrect in some places. See sources and examples!
22

3-
# GyverPower
4-
GyverPower - library for power management of MK AVR
5-
- System clock management
6-
- Enable/disable peripherals:
7-
-BOD
8-
- Timers
9-
- I2C/UART/SPI
3+
# Gyverpower
4+
Gyverpower - Library for Energy Executive Management MK AVR
5+
- System shock management
6+
- Turning on/off the periphery:
7+
- Bod
8+
- Tiemers
9+
- i2c/uart/spi
1010
- USB
11-
-ADC
12-
- Sleep in different modes (list below)
13-
- Sleep for any period
14-
- Timer calibration for accurate sleep time
15-
- millis() adjustment
16-
17-
### Compatibility
18-
- Atmega2560/32u4/328
11+
- ADC
12+
- sleep in different modes (list below)
13+
- sleep for any period
14+
- Tiemer calibration for the exact time of sleep
15+
- adjustment Millis ()
16+
17+
## compatibility
18+
- Atmega2560/32U4/328
1919
- Attiny85/84/167
2020

2121
### Documentation
22-
The library has [extended documentation](https://alexgyver.ru/GyverPower/)
22+
There is [expanded documentation] to the library (https://alexgyver.ru/gyverpower/)
2323

2424
## Content
25-
- [Install](#install)
26-
- [Initialization](#init)
27-
- [Usage](#usage)
28-
- [Example](#example)
29-
- [Versions](#versions)
30-
- [Bugs and feedback](#feedback)
31-
32-
<a id="install"></a>
25+
- [installation] (# Install)
26+
- [initialization] (#init)
27+
- [use] (#usage)
28+
- [Example] (# Example)
29+
- [versions] (#varsions)
30+
- [bugs and feedback] (#fedback)
31+
32+
<a id="install"> </a>
3333
## Installation
34-
- The library can be found by the name **GyverPower** and installed through the library manager in:
35-
- Arduino IDE
36-
- Arduino IDE v2
37-
- PlatformIO
38-
- [Download Library](https://github.com/GyverLibs/GyverPower/archive/refs/heads/main.zip) .zip archive for manual installation:
39-
- Unzip and put in *C:\Program Files (x86)\Arduino\libraries* (Windows x64)
40-
- Unzip and put in *C:\Program Files\Arduino\libraries* (Windows x32)
41-
- Unpack and put in *Documents/Arduino/libraries/*
42-
- (Arduino IDE) automatic installation from .zip: *Sketch/Include library/Add .ZIP library…* and specify the downloaded archive
43-
- Read more detailed instructions for installing librariesek [here] BA%D0%B0_%D0%B1%D0%B8%D0%B1%D0%BB%D0%B8%D0%BE%D1%82%D0%B5%D0%BA)
44-
45-
<a id="init"></a>
46-
## Initialization
47-
Not
48-
49-
<a id="usage"></a>
34+
- The library can be found by the name ** gyverpower ** and installed through the library manager in:
35+
- Arduino ide
36+
- Arduino ide v2
37+
- Platformio
38+
- [download the library] (https://github.com/gyverlibs/gyverpower/archive/refs/heads/main.zip) .Zip archive for manual installation:
39+
- unpack and put in * C: \ Program Files (X86) \ Arduino \ Libraries * (Windows X64)
40+
- unpack and put in * C: \ Program Files \ Arduino \ Libraries * (Windows X32)
41+
- unpack and put in *documents/arduino/libraries/ *
42+
- (Arduino id) Automatic installation from. Zip: * sketch/connect the library/add .Zip library ... * and specify downloaded archive
43+
- Read more detailed instructions for installing libraries [here] (https://alexgyver.ru/arduino-first/#%D0%A3%D1%81%D1%82%D0%B0%BD%D0%BE%BE%BE%BED0%B2%D0%BA%D0%B0_%D0%B1%D0%B8%D0%B1%D0%BB%D0%B8%D0%BE%D1%82%D0%B5%D0%BA)
44+
### Update
45+
- I recommend always updating the library: errors and bugs are corrected in the new versions, as well as optimization and new features are added
46+
- through the IDE library manager: find the library how to install and click "update"
47+
- Manually: ** remove the folder with the old version **, and then put a new one in its place.“Replacement” cannot be done: sometimes in new versions, files that remain when replacing are deleted and can lead to errors!
48+
49+
50+
<a id="init"> </a>
51+
## initialization
52+
No
53+
54+
<a id="usage"> </a>
5055
## Usage
51-
```cpp
52-
void hardwareEnable(uint16_t data); // enable the specified peripheral (see "Peripheral Constants" below)
53-
void hardwareDisable(uint16_tdata); // turn off the specified peripheral (see "Peripheral Constants" below)
54-
void setSystemPrescaler(prescalers_t prescaler);// set the system frequency divider (see "Divisor Constants" below)
55-
void adjustInternalClock(int8_tadj); // adjusting the frequency of the internal generator (number -120...+120)
56-
57-
void bodInSleep(bool en); // Brown-out detector in sleep mode (true on - false off) by default disabled!
58-
void setSleepMode(sleepmodes_t mode); // set the current sleep mode (see "Sleep Modes" below)
59-
void setSleepResolution(uint8_tperiod); // set sleep permission (see "Sleep periods" below)
60-
61-
void autoCalibrate(void); // automatic calibration of the sleep timer, runs 16ms
62-
void sleep(uint8_t period); // sleep for a fixed period (see "Sleep periods" below)
63-
uint8_t sleepDelay(uint32_t ms); // sleep for an arbitrary period in milliseconds (up to 52 days), returns the rest of the time to adjust the timers
64-
void correctMillis(bool state); // adjust millis for sleep time sleepDelay() (enabled by default)
65-
void wakeUp(void); // helps to exit sleepDelay with an interrupt (call in a wakeup interrupt)
66-
bool inSleep(void); // will return true if the MCU is sleeping (for checking in an interrupt)
67-
```
68-
69-
```cpp
70-
===== SLEEP MODES for setSleepMode() =====
71-
IDLE_SLEEP - Light sleep, turns off only the CPU and Flash clock, wakes up instantly from any interrupts
72-
ADC_SLEEP - Light sleep, turns off CPU and system clock, ADCstarts transformation when going to sleep (see ADCinSleep example)
73-
EXTSTANDBY_SLEEP - Deep sleep, identical to POWERSAVE_SLEEP + system clock active
74-
STANDBY_SLEEP - Deep sleep, identical to POWERDOWN_SLEEP + system clock active
75-
POWERSAVE_SLEEP - Deep sleep, identical to POWERDOWN_SLEEP + timer 2 active (+ can be woken up by its interrupts), can be used to count time (see powersaveMillis example)
76-
POWERDOWN_SLEEP - The deepest sleep, everything is turned off except WDT and external interrupts, wakes up from hardware (regular + PCINT) or WDT
77-
78-
===== SLEEP PERIODS for sleep() and setSleepResolution() =====
79-
SLEEP_16MS
80-
SLEEP_32MS
81-
SLEEP_64MS
82-
SLEEP_128MS
83-
SLEEP_256MS
84-
SLEEP_512MS
85-
SLEEP_1024MS
86-
SLEEP_2048MS
87-
SLEEP_4096MS
88-
SLEEP_8192MS
89-
SLEEP_FOREVER - eternal sleep
90-
91-
===== DIVISION CONSTANTS for setSystemPrescaler() =====
92-
PRESCALER_1
93-
PRESCALER_2
94-
PRESCALER_4
95-
PRESCALER_8
96-
PRESCALER_16
97-
PRESCALER_32
98-
PRESCALER_64
99-
PRESCALER_128
100-
PRESCALER_256
101-
102-
===== PERIPHERY CONSTANTS for hardwareDisable() and hardwareEnable() =====
103-
PWR_ALL - all hardware
104-
PWR_ADC - ADC and comparator
105-
PWR_TIMER1 - Timer 0
106-
PWR_TIMER0 - Timer 1
107-
PWR_TIMER2 - Timer 2
108-
PWR_TIMER3 - Timer 3
109-
PWR_TIMER4 - Timer 4
110-
PWR_TIMER5 - Timer 5
56+
`` `CPP
57+
VOID Hardwareenable (Uint16_T DATA);// inclusion of the specified periphery (see below the "peripheral constants")
58+
VOID HardwareDisable (Uint16_T DATA);// Turning off the specified periphery (see below the "Constant of the Periphery")
59+
VOID SetSystemprescaler (Prescalers_t PressCaler); // Installation of a system frequency divider (see below "Delichela Constant)
60+
VOID Adjustinternalclock (Int8_T Adj);// adjustment of the frequency of the internal generator (number -120 ...+120)
61+
62+
VOID BODINSLEP (BOOL EN);// Brown -out Detector in sleep mode (True vkl - False cap) by the silence.Disconnected!
63+
VOID setsleepmode (Sleepmodes_t Mode);// Installation of the current sleep regime (see below "Sleep modes")
64+
VOID setsleepResolution (Uint8_t Period);// Set a resolution of sleep (see below the "periods of sleep")
65+
66+
VOID autocalibrate (VOID);// Automatic calibration of sleep timer, 16 ms is performed
67+
VOID Sleep (Uint8_t Period);// sleep for a fixed period (see below "periods of sleep")
68+
Uint8_t SleepDelay (Uint32_T MS);// Sleep to arbitrary peRiodes in milliseconds (up to 52 days), returns the rest of the time to correct timers
69+
VOID Correctmillis (Bool State);// Correct millis for sleep time SleepDelay () (by default on)
70+
VOID Wakeup (VOID);// Helps to leave SleepDelay an interruption (call in a waking interruption)
71+
Bool Insleep (Void);// will return True if MK sleeps (for verification in interruption)
72+
`` `
73+
74+
`` `CPP
75+
===== Sleep modes for setsleepmode () =======
76+
Idle_sleep - light sleep, only a CPU and Flash clock is turned off, it wakes up instantly from any interruption
77+
ADC_SLEP is a light dream, CPU and System Clock are disconnected, ADC begins to transform it when leaving (see Adcinsleep example)
78+
Extstandby_sleep - deep sleep, identical to PowerSave_Sleep + System Clock is active
79+
Standby_sleep - deep sleep, identical to PowerDown_Sleep + System Clock is active
80+
PowerSave_Sleep - deep sleep, identical to powerdown_sleep + timer 2 is active ( + you can wake up from its interruptions), you can use time (see example of powerSavemillis)
81+
PowerDown_Sleep - the deepest sleep, everything is turned off except WDT and external interruptions, wakes up from hardware (ordinary + PCINT) or WDT
82+
83+
===== Sleep periods for Sleep () and setsleepresolution () ===========
84+
Sleep_16ms
85+
Sleep_32MS
86+
Sleep_64ms
87+
Sleep_128MS
88+
Sleep_256MS
89+
Sleep_512MS
90+
Sleep_1024ms
91+
Sleep_2048MS
92+
Sleep_4096ms
93+
Sleep_8192MS
94+
Sleep_Forever - Eternal Dream
95+
96+
===== The divider constant for setsyStemprescaler () ===========
97+
PressCaler_1
98+
PressCaler_2
99+
PressCaler_4
100+
PressCaler_8
101+
PressCaler_16
102+
PressCaler_32
103+
PressCaler_64
104+
PressCaler_128
105+
PressCaler_256
106+
107+
===== The periphery constants for Hardwareedisable () and Hardwareenable () ==========
108+
Pwr_all - all iron
109+
PWR_ADC - ACP and comparator
110+
PWR_Timer1 - timer 0
111+
PWR_Timer0 - TIMER 1
112+
PWR_Timer2 - TIMER 2
113+
PWR_Timer3 - TIMER 3
114+
PWR_Timer4 - TIMER 4
115+
PWR_Timer5 - TIMER 5
111116
PWR_UART0 - Serial 0
112117
PWR_UART1 - Serial 1
113118
PWR_UART2 - Serial 2
114119
PWR_UART3 - Serial 3
115120
PWR_I2C - Wire
116121
PWR_SPI - SPI
117122
PWR_USB - USB
118-
PWR_USI - Wire + Spi (ATtinyXX)
119-
PWR_LIN - USART LIN (ATtinyXX)
120-
```
121-
122-
### A simple dream
123-
- The sleep mode is configured in `power.setSleepMode()`, `POWERDOWN_SLEEP` is active by default (see the rest above).
124-
- To sleep - call `power.sleep()` specifying one of the standard periods (see above).
125-
- The actual sleep time will be slightly different as the "sleep timer" is not very accurate.
126-
127-
### Sleep for any period
128-
- The sleep mode is configured in `power.setSleepMode()`, `POWERDOWN_SLEEP` is active by default (see the rest above).
129-
- To sleep - call `power.sleepDelay()` specifying the period in milliseconds (`uint32_t`, up to ~50 days).
130-
*How it works? Just loop withabout standard sleep periods within this feature.*
131-
- By default, this function "sleeps" in periods of 128 milliseconds. Wake time between sleep periods is about 2.2 µs (at 16 MHz),
132-
which is 0.0017% of sleep time. Accordingly, the accuracy of sleep time is a multiple of one sleep period. This period can be set to
133-
`power.setSleepResolution()` which takes the same constants as `sleep()`. If you need more accurate sleep - you can set 16 ms (`SLEEP_16MS`),
134-
if the maximum power saving is 8 seconds (`SLEEP_8192MS`).
135-
- It is mandatory to call `power.wakeUp()` inside the interrupt handler to wake up prematurely on an interrupt.
136-
- Sleep `sleepDelay()` has two very useful features:
137-
- Sleep for a very precise period with a calibrated timer (see below)
138-
- Save time count `millis()` for sleep time (see sleeptime example)
139-
140-
### Timer calibration
141-
In version 2.0 of the library, calibration has been simplified: just call `power.autoCalibrate()` when starting the microcontroller. The function is executed ~16 ms.
142-
**Attention! power.setSleepResolution() must be called after the timer is calibrated.**
143-
144-
<a id="example"></a>
123+
PWR_USI - Wire + SPI (Attinyxx)
124+
PWR_LIN - USART LIN (Attinyxx)
125+
`` `
126+
127+
### simple sleep
128+
- Sleep mode is tuned in `Power.setsleepmode ()`, by default, `PowerDown_Sleep` is active (the rest see above).
129+
- To fall asleep, we call `Power.sleep ()` with one of the standard periods (see above).
130+
- The real time of sleep will be slightly different, since the "sleep timer" is not very accurate.
131+
132+
### sleep for any period
133+
- Sleep mode is tuned in `Power.setsleepmode ()`, by default, `PowerDown_Sleep` is active (the rest see above).
134+
- To fall asleep, we call `Power.sleepDelay ()` with a period in milliseconds (`uint32_t`, up to ~ 50 days).
135+
*How it works?Just a cycle with standard periods of sleep inside this function.*
136+
- By default, this function sleeps” with periods of 128 milliseconds.The wakefulness between the periods of sleep is about 2.2 μs (at 16 MHz),
137+
which is 0.0017% of the time of sleep.Accordingly, the accuracy of the time of sleep is multiple of one period of sleep.This period can be configured in
138+
`Power.SetSleepResolution ()`, which accepts the same constants as `Sleep ()`.If you need a more accurate dream, you can put 16 ms (`Sleep_16MS`),
139+
If the maximum energy conservation is 8 seconds (`Sleep_8192MS`).
140+
- For premature awakening for interruption, it is necessary to call `Power.wakeup ()` inside the interruption processor.
141+
- Sleep `SleepDelay ()` has two very useful opportunities:
142+
- sleep for a very accurate period with a calibrated timer (see below)
143+
- Preservation of the time account `millis ()` during sleep (see example of Sleeptime)
144+
145+
### Tymer Calibration
146+
In version 2.0 of the library, the calibration was simplified: it is enough to call `Power.autocalibrate ()` when the microcontroller is launched.The function is performed ~ 16 ms.
147+
**Attention!Power.SetsleepResolution () should be called after calibration of the timer. **
148+
149+
<a id="EXAMPLE"> </a>
145150
## Example
146-
See **examples** for other examples!
147-
```cpp
148-
// demo of library features
149-
#include <GyverPower.h>
151+
The rest of the examples look at ** Examples **!
152+
`` `CPP
153+
// Demo of the library capabilities
154+
#include <gyverpower.h>
150155

151-
void setup() {
152-
pinMode(13, OUTPUT); // set pin with LED to output
153-
Serial.begin(9600);
156+
VOID setup () {
157+
Pinmode (13, output);// set up inCranberries with LED output
158+
Serial.Begin (9600);
154159

155-
power.autoCalibrate(); // automatic calibration
160+
Power.autocalibrate ();// Automatic calibration
156161

157-
// disable unnecessary peripherals
158-
power.hardwareDisable(PWR_ADC | PWR_TIMER1); // see constant section in GyverPower.h delimited by " | "
162+
// Disconnecting unnecessary periphery
163+
Power.hardwardedisable (pwr_adc | pwr_timer1);// see Constant section in gyverpower.h, separating the sign "|
159164

160-
// system frequency control
161-
power.setSystemPrescaler(PRESCALER_2); // see constants in GyverPower.h
165+
// System frequency management
166+
Power.SetSySteMprescaler (Prescaler_2);// cm constants in gyverpower.h
162167

163-
// setting sleep parameters
164-
power.setSleepMode(STANDBY_SLEEP); // if you need a different sleep mode, see constants in GyverPower.h (default POWERDOWN_SLEEP)
165-
//power.bodInSleep(false); // it is recommended to turn off bod in sleep to save power (default is false - already off!!)
168+
// Sleep settings
169+
Power.Setsleepmode (Standby_Sleep);// If you need another sleep mode, cm constants in gyverpower.h (by default PowerDown_Sleep)
170+
//power.BodinSleep (False);// It is recommended to turn off BOD in a dream to preserve energy (by default FALSE - already turned off !!)
166171

167-
// single y examplesleep cranberry
168-
Serial.println("go to sleep");
169-
delay(100); // give time to send
172+
// Example of single care of sleep
173+
Serial.println ("Go to Sleep");
174+
DELAY (100);// Give the time to send
170175

171-
power.sleep(SLEEP_2048MS); // sleep ~ 2 seconds
176+
Power.sleep (Sleep_2048MS);// Sleep ~ 2 seconds
172177

173-
Serial.println("wake up!");
174-
delay(100); // give time to send
178+
Serial.println ("Wake Up!");
179+
DELAY (100);// Give the time to send
175180
}
176181

177-
void loop() {
178-
// example of a cyclic sleep
179-
sleepDelay(1500); // sleep 1.5 seconds
180-
digitalWrite(13, !digitalRead(13)); // invert the state on the pin
182+
VOID loop () {
183+
// example of cyclic sleep
184+
Power.SleepDelay (1500);// Sleep 1.5 seconds
185+
DigitalWrite (13,! DigitalRead (13));// Inverting the condition on the pin
181186
}
182-
```
183-
184-
<a id="versions"></a>
185-
## Versions
186-
- v1.2 - calibration fix
187-
- v1.3 - fix for 32U4
188-
- v1.4 - added adjustInternalClock
189-
- v1.5 - compatible with attini
190-
- v1.6 - more ATTINI compatibility
191-
- v1.7 - optimization, compatibility with ATtiny13
192-
- v1.8 - compatible with ATmega32U4
193-
- v2.0 - memory optimization, sleepDelay redone, you can accurately know the actual sleep time
194-
- v2.0.1 - fix compiler warnings
195-
- v2.0.2 - fixed ATtiny85 compilation error
196-
- v2.1 - added bool inSleep() to check if MK is sleeping
197-
198-
<a id="feedback"></a>
199-
## Bugs and feedback
200-
When you find bugs, create an **Issue**, or better, immediately write to the mail [[email protected]](mailto:[email protected])
201-
The library is open for revision and your **Pull Request**'s!
187+
`` `
188+
189+
<a id="versions"> </a>
190+
## versions
191+
- V1.2 - Calibration Fix
192+
- V1.3 - Fix for 32U4
193+
- v1.4 - Adjustinternalclock added
194+
- V1.5 - compatibility with Attini
195+
- V1.6 - more compatibility with Attini
196+
- V1.7 - optimization, compatibility with Attiny13
197+
- V1.8 - Compatibility with atmega32u4
198+
- V2.0 - memory optimization, redepdlavia remoded, you can definitely find out the actual sleep time
199+
- V2.0.1 - FIX Compiler Warnings
200+
- v2.0.2 - Fixed compilation error attiny85
201+
- V2.1 - Added Bool Insleep (), whether MK sleeps for verification
202+
- V2.2 - Improved stability
203+
204+
<a id="feedback"> </a>
205+
## bugs and feedback
206+
Create ** Issue ** when you find the bugs, and better immediately write to the mail [[email protected]] (mailto: [email protected])
207+
The library is open for refinement and your ** pull Request ** 'ow!
208+
209+
210+
When reporting about bugs or incorrect work of the library, it is necessary to indicate:
211+
- The version of the library
212+
- What is MK used
213+
- SDK version (for ESP)
214+
- version of Arduino ide
215+
- whether the built -in examples work correctly, in which the functions and designs are used, leading to a bug in your code
216+
- what code has been loaded, what work was expected from it and how it works in reality
217+
- Ideally, attach the minimum code in which the bug is observed.Not a canvas of a thousand lines, but a minimum code

0 commit comments

Comments
 (0)