summaryrefslogtreecommitdiff
path: root/src/driver/mmsubstate.cc
blob: cce252656d3662b49d43218a0b737b9a90b0241e (plain)
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
/*
 * Copyright 2020 Daniel Friesel
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */
#include "driver/mmsubstate.h"
#if defined(MULTIPASS_ARCH_HAS_I2C) && !defined(CONFIG_driver_softi2c)
#include "driver/i2c.h"
#else
#include "driver/soft_i2c.h"
#endif

void MicroMoodySubstate::setSubstates(unsigned char substateCount, unsigned char switchDuration, unsigned char power)
{
	txbuf[0] = substateCount;
	txbuf[1] = power;
	txbuf[2] = switchDuration;
	i2c.xmit(address, 3, txbuf, 0, txbuf);
}

void MicroMoodySubstate::sleep()
{
	setSubstates(1, 0, 0);
}

void MicroMoodySubstate::noSubstates(unsigned char power1, unsigned char power2)
{
	setSubstates(1, power1, power2);
}

void MicroMoodySubstate::twoSubstates(unsigned char switchDuration, unsigned char power)
{
	setSubstates(2, switchDuration, power);
}

void MicroMoodySubstate::fourSubstates(unsigned char switchDuration, unsigned char power)
{
	setSubstates(4, switchDuration, power);
}

void MicroMoodySubstate::eightSubstates(unsigned char switchDuration, unsigned char power)
{
	setSubstates(8, switchDuration, power);
}

MicroMoodySubstate moody(0x11);