Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add I2C DHT12 sensor #124

Merged
merged 22 commits into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Documents/AXP173.zh-CN.en.pdf
Binary file not shown.
Binary file added Documents/AXP192 Datasheet v1.13_cn.zh-CN.en.pdf
Binary file not shown.
Binary file added Documents/AXP202.pdf
Binary file not shown.
Binary file added Documents/SH1107_v2.1.pdf
Binary file not shown.
Binary file added Documents/ST7735S_v1.3.pdf
Binary file not shown.
5 changes: 3 additions & 2 deletions lib/files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set(SMOOTH_SOURCES
${smooth_dir}/application/io/i2c/MCP23017.cpp
${smooth_dir}/application/io/i2c/MCP23017.cpp
${smooth_dir}/application/io/i2c/DHT12.cpp
${smooth_dir}/application/io/i2c/AxpPMU.cpp
${smooth_dir}/application/io/spi/BME280SPI.cpp
${smooth_dir}/application/io/spi/BME280Core.cpp
${smooth_dir}/application/io/wiegand/Wiegand.cpp
Expand Down Expand Up @@ -94,20 +95,20 @@ set(SMOOTH_SOURCES
${smooth_dir}/core/timer/Timer.cpp
${smooth_dir}/core/timer/TimerService.cpp
${smooth_dir}/core/util/string_util.cpp

${smooth_inc_dir}/application/display/DisplayPin.h
${smooth_inc_dir}/application/display/DisplaySpi.h
${smooth_inc_dir}/application/display/DisplayTypes.h
${smooth_inc_dir}/application/display/DisplayCommands.h
${smooth_inc_dir}/application/display/ILI9341.h
${smooth_inc_dir}/application/display/SH1107.h
${smooth_inc_dir}/application/display/ST7735.h

${smooth_inc_dir}/application/io/spi/BME280SPI.h
${smooth_inc_dir}/application/io/spi/BME280Core.h
${smooth_inc_dir}/application/io/i2c/ADS1115.h
${smooth_inc_dir}/application/io/i2c/MCP23017.h
${smooth_inc_dir}/application/io/i2c/DHT12.h
${smooth_inc_dir}/application/io/i2c/AxpPMU.h
${smooth_inc_dir}/application/io/i2c/AxpRegisters.h
${smooth_inc_dir}/application/network/http/HTTPProtocol.h
${smooth_inc_dir}/application/network/http/HTTPServer.h
${smooth_inc_dir}/application/network/http/HTTPServerClient.h
Expand Down
22 changes: 9 additions & 13 deletions lib/smooth/application/display/DisplaySpi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,20 @@ namespace smooth::application::display
std::chrono::milliseconds active_time,
std::chrono::milliseconds delay_time)
{
auto search = display_pins.find("reset");

if (search != display_pins.end())
if (reset_pin != nullptr)
{
if (active_low)
{
search->second->set_output_level(PIN_LOW); // force the display chip to reset
reset_pin->set_output_level(PIN_LOW); // force the display chip to reset
std::this_thread::sleep_for(active_time);
search->second->set_output_level(PIN_HIGH);
reset_pin->set_output_level(PIN_HIGH);
std::this_thread::sleep_for(delay_time);
}
else
{
search->second->set_output_level(PIN_HIGH); // force the display chip to reset
reset_pin->set_output_level(PIN_HIGH); // force the display chip to reset
std::this_thread::sleep_for(active_time);
search->second->set_output_level(PIN_HIGH);
reset_pin->set_output_level(PIN_HIGH);
std::this_thread::sleep_for(delay_time);
}
}
Expand Down Expand Up @@ -424,23 +422,21 @@ namespace smooth::application::display
// Add reset pin
void DisplaySpi::add_reset_pin(std::unique_ptr<DisplayPin> reset_pin)
{
display_pins["reset"] = std::move(reset_pin);
reset_pin = std::move(reset_pin);
}

// Add backlight pin
void DisplaySpi::add_backlight_pin(std::unique_ptr<DisplayPin> bk_light_pin)
{
display_pins["bklight"] = std::move(bk_light_pin);
backlight_pin = std::move(bk_light_pin);
}

// Set backlight pin level
void DisplaySpi::set_back_light(bool level)
{
auto search = display_pins.find("bklight");

if (search != display_pins.end())
if (backlight_pin != nullptr)
{
search->second->set_output_level(level);
backlight_pin->set_output_level(level);
}
}
}
Loading