GyverLibs / microDS18B20

Легкая и удобная в обращении библиотека для работы с 1-Wire термометрами DS18B20
MIT License
45 stars 11 forks source link

some questions about multithread. #1

Closed youxiaojie closed 3 years ago

youxiaojie commented 3 years ago

1. int DS_rawToInt ( uint16_t data); // convert raw data to int temperature float DS_rawToFloat ( uint16_t data); // convert raw data to float temperature

and DS_TEMP_TYPE calcRaw ( uint16_t data) { return ((DS_TEMP_TYPE) data / 16 ); // Calculate the temperature value }

are the same, why define two funtion?

  1. if I want use multithread, shoud I change delay() to millis()-startime>= period format?
  2. is your code must cooperate with your microwire lib?
  3. did your two libs take less resources than officials? thanks!
GyverLibs commented 3 years ago

Hello!

  1. DS_rawToInt/DS_rawToFloat are outside of class, so you can use it for convert raw data from transmission from other device without creating a microDS18b20 object
  2. Of course, good code should not contain delays() at all! You can use TimerMS library or GyverOS task manager
  3. No, microWire is I2C, this library is OneWire interface
  4. All my libs are highly optimized and take less resources, especially "micro". microDS18b20 can be running on Attiny13 and take just 300 B of Flash, while Dallas library takes about 2.5 kB Flash and almost all SRAM memory =)
youxiaojie commented 3 years ago

1.sorry, misspell, microOneWire.h, if I use your microds18b20, I don't need official onewire lib.

  1. I see your two .h files contain delay(), If I cooperate with taskscheduler or gyveros, need I rewrite two .h to change delay() to millis()-startime>= period format.

All my libs are highly optimized and take less resources, especially "micro". microDS18b20 can be running on Attiny13 and take just 300 kB of Flash, while Dallas library takes about 2.5 kB Flash and almost all SRAM memory =)?? 300kB? a typo?

GyverLibs commented 3 years ago
  1. Of course, you dont need official lib, it is not included nowhere in code
  2. Delays in library provide one wire interface, you cant rid of them because of timing. Communication by one wire takes a little time, dont worry about it. If you about examples and delay(1000) - use millis() timer algorithm or some timer library as i meant above
  3. Yes, typo. 300 Bytes of course i mean