Skip to content

Commit

Permalink
update readme.md (#26)
Browse files Browse the repository at this point in the history
- update readme.md
- add ledbar example
  • Loading branch information
RobTillaart authored Nov 13, 2023
1 parent 351991f commit 343935a
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 7 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.2.7] - 2023-11-13
- update readme.md
- add ledbar example


## [0.2.6] - 2023-08-15
- optimize 16 bit interface
- add readReg16() + writeReg16()
Expand All @@ -14,7 +19,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- update readme.md
- minor edits


## [0.2.5] - 2023-08-14
- add ESP32 HSPI / VSPI support (Kudo's to Alex Uta, PR #22)
- add **performance_0.2.4.md** for ESP32
Expand Down
2 changes: 1 addition & 1 deletion MCP23S17.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: MCP23S17.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.2.6
// VERSION: 0.2.7
// PURPOSE: Arduino library for SPI MCP23S17 16 channel port expander
// DATE: 2021-12-30
// URL: https://github.com/RobTillaart/MCP23S17
Expand Down
4 changes: 2 additions & 2 deletions MCP23S17.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// FILE: MCP23S17.h
// AUTHOR: Rob Tillaart
// VERSION: 0.2.6
// VERSION: 0.2.7
// PURPOSE: Arduino library for SPI MCP23S17 16 channel port expander
// DATE: 2021-12-30
// URL: https://github.com/RobTillaart/MCP23S17
Expand All @@ -13,7 +13,7 @@
#include "MCP23S17_registers.h"


#define MCP23S17_LIB_VERSION (F("0.2.6"))
#define MCP23S17_LIB_VERSION (F("0.2.7"))

// ERROR CODES
#define MCP23S17_OK 0x00
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
[![Arduino CI](https://github.com/RobTillaart/MCP23S17/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/MCP23S17/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/MCP23S17/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/MCP23S17/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/MCP23S17/actions/workflows/jsoncheck.yml)
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/MCP23S17.svg)](https://github.com/RobTillaart/MCP23S17/issues)

[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/MCP23S17/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/MCP23S17.svg?maxAge=3600)](https://github.com/RobTillaart/MCP23S17/releases)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/MCP23S17.svg)](https://registry.platformio.org/libraries/robtillaart/MCP23S17)


# MCP23S17
Expand Down Expand Up @@ -244,3 +247,12 @@ See examples.
#### Wont


## Support

If you appreciate my libraries, you can support the development and maintenance.
Improve the quality of the libraries by providing issues and Pull Requests, or
donate through PayPal or GitHub sponsors.

Thank you,


81 changes: 81 additions & 0 deletions examples/MCP23S17_test_led_bar/MCP23S17_test_led_bar.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//
// FILE: MCP23S17_test_led_bar.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo MCP23S17 control of LED bar
// URL: https://github.com/RobTillaart/MCP23S17
//
// control of a 10-line LED bar, via pin 0..9 (Think VU meter etc)
// 2 different methods, one by one versus 16 bit mask
// bit mask is faster (~6x) for both HW SPI and SW SPI


#include "MCP23S17.h"
#include "SPI.h"


// MCP23S17 MCP(10, 12, 11, 13); // SW SPI address 0x00
MCP23S17 MCP(10); // HW SPI address 0x00

uint32_t start, stop;

void setup()
{
Serial.begin(115200);
Serial.println();
Serial.print("MCP23S17_LIB_VERSION: ");
Serial.println(MCP23S17_LIB_VERSION);
Serial.println();
delay(100);

SPI.begin();
bool b = MCP.begin();
Serial.println(b ? "true" : "false");

// all pins output
MCP.pinMode16(0x0000); // 0 = output, 1 = input
delay(100);
}


void loop()
{
int x = analogRead(A0); // 0 .. 1023
delay(100);

start = micros();
ledbar_1(x / 100); // 0 .. 10
stop = micros();
Serial.print("Time 1:\t");
Serial.println(stop - start);
delay(1000);

start = micros();
ledbar_2(x / 100); // 0 .. 10
stop = micros();
Serial.print("Time 2:\t");
Serial.println(stop - start);
Serial.println();
delay(1000);
}


void ledbar_1(int x)
{
// set leds one at a time.
int i = 0;
while (i++ < x)
{
MCP.digitalWrite(i, HIGH);
}
while (i++ < 10) MCP.digitalWrite(i, LOW);
}


void ledbar_2(int x)
{
// use 16 bit bitmask.
uint16_t n = (1 << x) - 1;
MCP.write16(n);
}

// -- END OF FILE --
4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"type": "git",
"url": "https://github.com/RobTillaart/MCP23S17.git"
},
"version": "0.2.6",
"version": "0.2.7",
"license": "MIT",
"frameworks": "arduino",
"frameworks": "*",
"platforms": "*",
"headers": "MCP23S17.h"
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=MCP23S17
version=0.2.6
version=0.2.7
author=Rob Tillaart <[email protected]>
maintainer=Rob Tillaart <[email protected]>
sentence=Arduino library for SPI MCP23S17 16 channel port expander 16 IO-lines
Expand Down

0 comments on commit 343935a

Please sign in to comment.