aboutsummaryrefslogtreecommitdiff
path: root/Marlin/src/feature/leds/pca9533.h
blob: 431058c491363e381e41e39daac1db829ad71232 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * Marlin 3D Printer Firmware
 * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
 *
 * Based on Sprinter and grbl.
 * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 */
#pragma once

/*
 * Driver for the PCA9533 LED controller found on the MightyBoard
 * used by FlashForge Creator Pro, MakerBot, etc.
 * Written 2020 APR 01 by grauerfuchs
 */
#include <Arduino.h>

#define ENABLE_I2C_PULLUPS

// Chip address (for Wire)
#define PCA9533_Addr        0xC4

// Control registers
#define PCA9533_REG_READ    0x00
#define PCA9533_REG_PSC0    0x01
#define PCA9533_REG_PWM0    0x02
#define PCA9533_REG_PSC1    0x03
#define PCA9533_REG_PWM1    0x04
#define PCA9533_REG_SEL     0x05
#define PCA9533_REGM_AI     0x10

// LED selector operation
#define PCA9533_LED_OP_OFF  0B00
#define PCA9533_LED_OP_ON   0B01
#define PCA9533_LED_OP_PWM0 0B10
#define PCA9533_LED_OP_PWM1 0B11

// Select register bit offsets for LED colors
#define PCA9533_LED_OFS_RED 0
#define PCA9533_LED_OFS_GRN 2
#define PCA9533_LED_OFS_BLU 4

void PCA9533_init();
void PCA9533_reset();
void PCA9533_set_rgb(uint8_t red, uint8_t green, uint8_t blue);
void PCA9533_setOff();