Skip to content

Commit

Permalink
1.0.1
Browse files Browse the repository at this point in the history
1.0.1: jm_Write.h and jm_Wire.cpp files are now exactly the same as the
original Wire.h and Wire.cpp as found in Arduino 1.8.2 with a little
update of declaratives in jm_Wire.cpp.
All true updates are in files jm_twi.h and jm_twi.c.
  • Loading branch information
jmparatte committed May 3, 2017
1 parent cc48cb4 commit 6599a72
Show file tree
Hide file tree
Showing 11 changed files with 493 additions and 379 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!--
2017-05-03: 1.0.1
2017-05-01: Initial commit.
Licence: LGPL v3
Expand All @@ -8,28 +9,39 @@ Author: Jean-Marc Paratte
Email: jean-marc@paratte.ch
-->
# jm_Wire - A revisited Wire Library for Arduino
# jm_Wire - Revisited Wire Library for Arduino

2017-05-03: 1.0.1

2017-05-01: Initial commit.

This library eliminate all freezing cases and waiting loop.
This library eliminate all freezing cases and waiting loops.

The provided _jm_LiquidCrystal_I2C_demo_ example demonstrates how it is possible
to send data to a Hitachi HD44780 or compatible chipsets via I2C without abandon multitasking request.
To illustrate the last sentence, think that the Hitachi HD44780 need about 4.5ms to initialize it or clear it.
The example shows also how to write I2C packets with various delays, by using a fifo buffer.
The multitasking is provided by the jm_Scheduler library.

1.0.1: jm_Write.h and jm_Wire.cpp files are now exactly the same as the original Wire.h and Wire.cpp as found in Arduino 1.8.2 with a little update of declaratives in jm_Wire.cpp.
All true updates are in files jm_twi.h and jm_twi.c.

## Example

#include <jm_Scheduler.h>
#include <jm_Wire.h>
extern uint16_t twi_readFrom_timeout;
extern uint16_t twi_writeTo_timeout;
extern bool twi_readFrom_wait;
extern bool twi_writeTo_wait;

// your code...

void setup(void)
{
Wire.begin();
twi_readFrom_wait = false; // Suppress twi_readFrom() waiting loop
twi_writeTo_wait = false; // Suppress twi_writeTo() waiting loop
}

void loop(void)
Expand Down
9 changes: 0 additions & 9 deletions examples/jm_LiquidCrystal_I2C_demo/LiquidCrystal_I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,10 @@ void LiquidCrystal_I2C::pulseEnable (uint8_t data)
wait(200);
_i2cio.write (data & ~_En); // En LOW
wait(200);
#else
#if 0
lcd_i2c_write(data);
#else
_i2cio.write (data | _En); // En HIGH
_i2cio.write (data & ~_En); // En LOW
#endif
#endif
}

void LiquidCrystal_I2C::wait(uint16_t us)
Expand All @@ -314,12 +310,7 @@ void LiquidCrystal_I2C::wait(uint16_t us)

#if 0
delayMicroseconds( us );
#else
#if 0
lcd_i2c_write(0xFF);
lcd_i2c_write((us + (20 - 1))/20);
#else
_i2cio.wait(us);
#endif
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

//#include <Wire.h>
#include <jm_Wire.h>
extern uint16_t twi_readFrom_timeout;
extern uint16_t twi_writeTo_timeout;
extern bool twi_readFrom_wait;
extern bool twi_writeTo_wait;

////////////////////////////////////////////////////////////////////////////////

Expand All @@ -26,7 +30,6 @@ const uint8_t charBitmap[8][8] = {
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F }

};

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -99,6 +102,9 @@ void setup()
Serial.println();

Wire.begin();
twi_readFrom_wait = false; // Suppress twi_readFrom() waiting loop
twi_writeTo_wait = false; // Suppress twi_writeTo() waiting loop


lcd.begin();
while (lcd._i2cio.yield_request()) jm_Scheduler::yield();
Expand Down
Loading

0 comments on commit 6599a72

Please sign in to comment.