A library for interfacing with the SN74HC595N Shift register. Includes functions for writing bits, bytes, animation and bits at spesified positions.
ShiftOut.h
- Committer:
- benrammok
- Date:
- 2015-12-25
- Revision:
- 2:88581826b53c
- Parent:
- 1:c89861664726
- Child:
- 3:a0df8989ffa2
File content as of revision 2:88581826b53c:
/* Copyright 2015 Benjamin R. Moeklegaard Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. This is a library for easy interfacing with the SN74HC595N 8-bit Shift Register. The library includes functions for writing bits, bytes and animation array to the register. The Functions are mainly based for writting 8-bits or one byte and can be moddified to work with multiple shift registers. */ #ifndef SHIFT_H #define SHIFT_H class ShiftOut { public: ShiftOut(PinName ser, PinName srclk, PinName rclk, PinName oe, PinName reset); /** */ void writeByte(unsigned char); /** * @param: 0xXX or numbers from 0-255 * @note Writes a byte to the shift register */ /** */ void writeBit(unsigned char); /** * @param: 0 or 1 * @note Writes a bit to the first output on the shift register */ /** */ void animate(int[][8], int, int); /** * @param: int array * @note Writes bits from an 2D array, with configurable delay */ /** */ void animationExample(void); /** * @note Shows two animation examples */ /** */ void writeBitAtPos(unsigned char, bool); /** * @param: output, state * Writes to the desired state to the output on the shift register */ /** */ void writeArray(char[8]); /** * @param: char array * Writes the corresponding array item to the output on the shift register */ protected: void updateRegister(void); void updateOutput(void); DigitalOut DSERIAL, LATCH, RCLK, SRCLK, RESET; }; #endif