Skip to content

Commit

Permalink
#298 Add screenshot menu, adjust LCD colours (#299)
Browse files Browse the repository at this point in the history
* Change default LCD scheme by request

* add snapshot to menu (#298)
  • Loading branch information
vintagepc authored Mar 20, 2021
1 parent f6f1af8 commit 14c0b33
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cppcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
# This workflow contains a single job called "build"
cppcheck:
# The type of runner that the job will run on
runs-on: ubuntu-latest
runs-on: ubuntu-18.04

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
# This workflow contains a single job called "build"
part_tests:
# The type of runner that the job will run on
runs-on: ubuntu-latest
runs-on: ubuntu-18.04

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:

ext1_tests:
# The type of runner that the job will run on
runs-on: ubuntu-latest
runs-on: ubuntu-18.04

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand Down Expand Up @@ -190,7 +190,7 @@ jobs:

Upload_Coverage:
# The type of runner that the job will run on
runs-on: ubuntu-latest
runs-on: ubuntu-18.04
needs: [ext1_tests, part_tests]
steps:

Expand Down
46 changes: 23 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -465,32 +465,32 @@ foreach (TEST_SRC IN LISTS TESTS_SOURCES)
)
endforeach()

add_test(ext1_MK1_Boot env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK1_mR13 -f ../assets/Firmware/MK1-mR13a.hex --script ../scripts/tests/test_boot_MK1.txt)
add_test(ext1_MK2_Boot env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK2_mR13 -f ../assets/Firmware/MK2-mR13a.hex --script ../scripts/tests/test_boot_MK2.txt)
add_test(ext1_MK2MMU_Boot env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK2MMU_mR13 -f ../assets/Firmware/MK2MMU-mR13a.hex --script ../scripts/tests/test_boot_MK2MMU.txt)
add_test(ext1_MK25_Boot env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK25_mR13 -f ../assets/Firmware/MK25-mR13a.hex --script ../scripts/tests/test_boot_MK25.txt)
add_test(ext1_MK25S_Boot env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK25S_mR13 -f ../assets/Firmware/MK25S-mR13a.hex --script ../scripts/tests/test_boot_MK25S.txt)
add_test(ext1_MK3S_Boot env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3S -f MK3S.afx --script ../scripts/tests/test_boot_MK3S.txt)
add_test(ext1_MK3_Boot env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3 -f MK3S.afx --script ../scripts/tests/test_boot_MK3.txt)
add_test(ext1_MK3SMMU2_Boot env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3SMMU2 -f MK3S.afx --script ../scripts/tests/test_boot_MK3SMMU2.txt)
add_test(ext1_MK3MMU2_Boot env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3MMU2 -f MK3S.afx --script ../scripts/tests/test_boot_MK3MMU2.txt)
add_test(ext1_Lite_Gfx env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 -g lite -f tests/extra_EinsyRambo.afx --script ../scripts/tests/test_lite_gfx.txt)
add_test(ext1_Bear_Gfx env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 -g bear -f tests/extra_EinsyRambo.afx --script ../scripts/tests/test_bear_gfx.txt)
add_test(ext1_Fancy_Gfx env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 -g fancy -f tests/extra_EinsyRambo.afx --script ../scripts/tests/test_fancy_gfx.txt)
add_test(ext1_Lite_MMU_Gfx env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3SMMU2 -g lite -f tests/extra_EinsyRambo.afx --script ../scripts/tests/test_litemmu_gfx.txt)
add_test(ext1_Fancy_MMU_Gfx env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3SMMU2 -g fancy -f tests/extra_EinsyRambo.afx --script ../scripts/tests/test_fancymmu_gfx.txt)
add_test(ext1_Mouse env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3S -f tests/extra_EinsyRambo.afx -g lite --script ../scripts/tests/test_lite_gfx_mouse.txt)
add_test(ext1_Keys env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3 -f tests/extra_EinsyRambo.afx -g lite --script ../scripts/tests/test_lite_gfx_keys.txt)
add_test(ext1_MK2_Fancy env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK2_mR13 -f tests/extra_MiniRambo.afx -g fancy --script ../scripts/tests/test_MK2_fancy.txt)
add_test(ext1_MK2MMU_Fancy env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK2MMU_mR13 -f tests/extra_MiniRambo.afx -g fancy --script ../scripts/tests/test_MK2MMU_fancy.txt)
add_test(ext1_MK25_Fancy env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK25_mR13 -f tests/extra_MiniRambo.afx -g fancy --script ../scripts/tests/test_MK25_fancy.txt)
add_test(ext1_MK2_Lite env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK25_mR13 -f tests/extra_MiniRambo.afx -g lite --script ../scripts/tests/test_MK2_lite.txt)
add_test(ext1_MK1_Boot env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK1_mR13 -f ../assets/Firmware/MK1-mR13a.hex --script ../scripts/tests/test_boot_MK1.txt --lcd-scheme 2 )
add_test(ext1_MK2_Boot env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK2_mR13 -f ../assets/Firmware/MK2-mR13a.hex --script ../scripts/tests/test_boot_MK2.txt --lcd-scheme 2 )
add_test(ext1_MK2MMU_Boot env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK2MMU_mR13 -f ../assets/Firmware/MK2MMU-mR13a.hex --script ../scripts/tests/test_boot_MK2MMU.txt --lcd-scheme 2 )
add_test(ext1_MK25_Boot env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK25_mR13 -f ../assets/Firmware/MK25-mR13a.hex --script ../scripts/tests/test_boot_MK25.txt --lcd-scheme 2 )
add_test(ext1_MK25S_Boot env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK25S_mR13 -f ../assets/Firmware/MK25S-mR13a.hex --script ../scripts/tests/test_boot_MK25S.txt --lcd-scheme 2 )
add_test(ext1_MK3S_Boot env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3S -f MK3S.afx --script ../scripts/tests/test_boot_MK3S.txt --lcd-scheme 2 )
add_test(ext1_MK3_Boot env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3 -f MK3S.afx --script ../scripts/tests/test_boot_MK3.txt --lcd-scheme 2 )
add_test(ext1_MK3SMMU2_Boot env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3SMMU2 -f MK3S.afx --script ../scripts/tests/test_boot_MK3SMMU2.txt --lcd-scheme 2 )
add_test(ext1_MK3MMU2_Boot env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3MMU2 -f MK3S.afx --script ../scripts/tests/test_boot_MK3MMU2.txt --lcd-scheme 2 )
add_test(ext1_Lite_Gfx env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 -g lite -f tests/extra_EinsyRambo.afx --script ../scripts/tests/test_lite_gfx.txt --lcd-scheme 2 )
add_test(ext1_Bear_Gfx env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 -g bear -f tests/extra_EinsyRambo.afx --script ../scripts/tests/test_bear_gfx.txt --lcd-scheme 2 )
add_test(ext1_Fancy_Gfx env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 -g fancy -f tests/extra_EinsyRambo.afx --script ../scripts/tests/test_fancy_gfx.txt --lcd-scheme 2 )
add_test(ext1_Lite_MMU_Gfx env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3SMMU2 -g lite -f tests/extra_EinsyRambo.afx --script ../scripts/tests/test_litemmu_gfx.txt --lcd-scheme 2 )
add_test(ext1_Fancy_MMU_Gfx env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3SMMU2 -g fancy -f tests/extra_EinsyRambo.afx --script ../scripts/tests/test_fancymmu_gfx.txt --lcd-scheme 2 )
add_test(ext1_Mouse env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3S -f tests/extra_EinsyRambo.afx -g lite --script ../scripts/tests/test_lite_gfx_mouse.txt --lcd-scheme 2 )
add_test(ext1_Keys env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3 -f tests/extra_EinsyRambo.afx -g lite --script ../scripts/tests/test_lite_gfx_keys.txt --lcd-scheme 2 )
add_test(ext1_MK2_Fancy env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK2_mR13 -f tests/extra_MiniRambo.afx -g fancy --script ../scripts/tests/test_MK2_fancy.txt --lcd-scheme 2 )
add_test(ext1_MK2MMU_Fancy env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK2MMU_mR13 -f tests/extra_MiniRambo.afx -g fancy --script ../scripts/tests/test_MK2MMU_fancy.txt --lcd-scheme 2 )
add_test(ext1_MK25_Fancy env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK25_mR13 -f tests/extra_MiniRambo.afx -g fancy --script ../scripts/tests/test_MK25_fancy.txt --lcd-scheme 2 )
add_test(ext1_MK2_Lite env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK25_mR13 -f tests/extra_MiniRambo.afx -g lite --script ../scripts/tests/test_MK2_lite.txt --lcd-scheme 2 )

# TODO- move these images out of parts and to their own ext2 dir...
add_test(ext2_Print_prep cp ../scripts/tests/Prusa_MK3S_eeprom.bin_test ${PROJECT_BINARY_DIR})
add_test(ext2_Print env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3S -f MK3S.afx -g lite --sdimage Test.img --script ../scripts/tests/test_GLPrint.txt)
add_test(ext2_Print_HRQ env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3S -f MK3S.afx -g lite --sdimage Test.img --script ../scripts/tests/test_GLPrint_HRQ.txt --extrusion Quad_HR --colour-extrusion)
add_test(ext2_Print_TAvg env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3S -f MK3S.afx -g lite --sdimage Test.img --script ../scripts/tests/test_GLPrint_AvgT.txt --extrusion Tube_Avg)
add_test(ext2_Print env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3S -f MK3S.afx -g lite --sdimage Test.img --script ../scripts/tests/test_GLPrint.txt --lcd-scheme 2 )
add_test(ext2_Print_HRQ env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3S -f MK3S.afx -g lite --sdimage Test.img --script ../scripts/tests/test_GLPrint_HRQ.txt --extrusion Quad_HR --colour-extrusion --lcd-scheme 2 )
add_test(ext2_Print_TAvg env ${TEST_EXPORT_PREFIX} ${TEST_XVFB_PREFIX} ./MK404 Prusa_MK3S -f MK3S.afx -g lite --sdimage Test.img --script ../scripts/tests/test_GLPrint_AvgT.txt --extrusion Tube_Avg --lcd-scheme 2 )

# This is a bit meaningless if your system doesn't generate the same renderings as the BR.
if(RUNNER_ENV)
Expand Down
2 changes: 2 additions & 0 deletions MK404.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ int main(int argc, char *argv[])
SwitchArg argMute("m","mute","Tell a printer to mute any audio it may produce.", cmd);
SwitchArg argMarlin("","marlin","Synonym for --no-hacks",cmd,false);
SwitchArg argLoad("l","loadfw","Directs the printer to load the default firmware file. (-f implies -l) If neither -l or -f are provided, the printer executes solely from its persisted flash.", cmd);
ValueArg<uint8_t> argLCDSCheme("","lcd-scheme", "Sets the default LCD colour scheme index, 0, 1, or 2",false, 0,"0-2",cmd);
SwitchArg argKlipper("","klipper","Synonym for --skew-correct and --no-hacks",cmd,false);
SwitchArg argKeyHelp("k","keys","Prints the list of available keyboard controls",cmd,false);
std::vector<string> vstrSizes = FatImage::GetSizes();
Expand Down Expand Up @@ -383,6 +384,7 @@ int main(int argc, char *argv[])

m_bTestMode = (argModel.getValue()=="Test_Printer") | argTest.isSet();

Config::Get().SetLCDScheme(argLCDSCheme.getValue());
Config::Get().SetExtrusionMode(PrintVisualType::GetNameToType().at(argExtrusion.getValue()));
Config::Get().SetColourE(argColourE.isSet());

Expand Down
15 changes: 14 additions & 1 deletion parts/components/GLHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <scoped_allocator> // NOLINT for allocator_traits<>::value_type
#include <solid_pixel_buffer.hpp> // NOLINT for solid_pixel_buffer
#endif // SUPPORTS_LIBPNG
#include <chrono>
#include <ctime>
#include <fstream> // IWYU pragma: keep
#include <iomanip>
#include <iostream>
Expand All @@ -46,6 +48,8 @@ GLHelper::GLHelper(const std::string &strName):Scriptable(strName)
RegisterAction("CheckPixel","Checks the pixel color at the given position matches specified (x,y,RGBA).",ActCheckPixel, {ArgType::uint32,ArgType::uint32, ArgType::uint32});
RegisterAction("Snapshot", "Takes a snap of the current GL rendering", ActTakeSnapshot, {ArgType::String});
RegisterAction("SnapRect", "Takes a snap a region (file,x,y,w,h)", ActTakeSnapshotArea, {ArgType::String,ArgType::Int,ArgType::Int,ArgType::Int,ArgType::Int});
RegisterActionAndMenu("AutoSnap", "Takes a snap of the current GL rendering and gives it the current date/time.", ActTakeSnapDT);

}

// Function for running the GL stuff inside the GL context.
Expand All @@ -71,6 +75,7 @@ void GLHelper::OnDraw()
}
break;
case ActTakeSnapshot:
case ActTakeSnapDT:
{
m_w = width;
m_h = height;
Expand Down Expand Up @@ -180,11 +185,19 @@ IScriptable::LineStatus GLHelper::ProcessAction(unsigned int iAct, const std::ve
break;
case ActTakeSnapshot:
case ActTakeSnapshotArea:
case ActTakeSnapDT:
{
bool bIsArea = iAct == ActTakeSnapshotArea;
if (m_iState == St_Idle)
{
m_strFile = vArgs.at(0) + ".png";
if (iAct == ActTakeSnapDT) {
auto tNow = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
m_strFile = std::ctime(&tNow);
m_strFile = m_strFile.substr(0,m_strFile.size()-1);// strip newline.
m_strFile += ".png";
} else {
m_strFile = vArgs.at(0) + ".png";
}
if (bIsArea)
{
m_x = std::stoi(vArgs.at(1));
Expand Down
3 changes: 2 additions & 1 deletion parts/components/GLHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class GLHelper: public Scriptable
{
ActCheckPixel,
ActTakeSnapshot,
ActTakeSnapshotArea
ActTakeSnapshotArea,
ActTakeSnapDT
};
enum ActState
{
Expand Down
5 changes: 3 additions & 2 deletions parts/components/HD44780GL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "HD44780GL.h"
#include "BasePeripheral.h" // for MAKE_C_CALLBACK
#include "Config.h"
#include "Macros.h"
#include "Util.h" // for hexColor_t, hexColor_t::(anonymous)
#include "gsl-lite.hpp"
Expand Down Expand Up @@ -81,14 +82,14 @@ void HD44780GL::OnKeyPress(const Key& key)
{
if (key =='1')
{
m_iScheme = (m_iScheme+1)%2;
m_iScheme = (m_iScheme+1)%3;
}
}

void HD44780GL::Init(avr_t *avr)
{
HD44780::Init(avr);

m_iScheme = Config::Get().GetLCDScheme()%3;
RegisterNotify(BRIGHTNESS_IN, MAKE_C_CALLBACK(HD44780GL, OnBrightnessDigital),this);
RegisterNotify(BRIGHTNESS_PWM_IN, MAKE_C_CALLBACK(HD44780GL, OnBrightnessPWM),this);
}
Expand Down
5 changes: 3 additions & 2 deletions parts/components/HD44780GL.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class HD44780GL:public HD44780, private IKeyClient

GLuint m_bgVtxBuffer = 0;
std::vector<uint32_t> m_colors = {
0x02c5fbff, 0x8d7ff8ff, 0xFFFFFFff, 0x00000055,
0x382200ff, 0x000000ff , 0xFF9900ff, 0x00000055};
0x0066ccff, 0x0a02ebff, 0xFFFFFFff, 0x00000055,
0x382200ff, 0x000000ff , 0xFF9900ff, 0x00000055,
0x02c5fbff, 0x8d7ff8ff, 0xFFFFFFff, 0x00000055,};
};
Binary file modified scripts/tests/snaps/ext1/GFXLiteKey08a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified scripts/tests/snaps/ext1/GFXLiteKey11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified scripts/tests/snaps/ext1/GFXLiteKey11a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified scripts/tests/snaps/ext1/GFXLiteKey12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions utility/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ class Config
inline void SetSkewCorrect(bool bVal){ m_bSkew = bVal;}
inline bool GetSkewCorrect(){ return m_bSkew;}

// Starting LCD colour scheme
inline void SetLCDScheme(uint8_t iVal){ m_iScheme = iVal;}
inline uint8_t GetLCDScheme(){ return m_iScheme;}

private:
unsigned int m_iExtrusion = false;
bool m_bColorExtrusion = false;
bool m_bSkew = false;
uint8_t m_iScheme = 0;

};

0 comments on commit 14c0b33

Please sign in to comment.