diff --git a/sample/PGEX_SMX.h b/sample/PGEX_SMX.h new file mode 100644 index 0000000..fa92b13 --- /dev/null +++ b/sample/PGEX_SMX.h @@ -0,0 +1,56 @@ +#pragma once +#include "olcPixelGameEngine.h" +#include "SMX.h" + +using namespace olc; + + +class PGEX_SMX : public PGEX{ + +public: + PGEX_SMX():PGEX(true){}; + //SMX "screen" is 12x21 + //Each panel is 4x7 + static void SMXStateChangedCallback(int pad, SMXUpdateCallbackReason reason, void *pUser) + { + PGEX_SMX *pSelf = (PGEX_SMX*) pUser; + pSelf->SMXStateChanged( pad, reason ); + } + + static void SMXLogCallback(const char *log) + { + printf("-> %s\n", log); + } + + void SMXStateChanged(int pad, SMXUpdateCallbackReason reason) + { + printf("Device %i state changed: %04x\n", pad, SMX_GetInputState(pad)); + + } + + virtual void OnAfterUserCreate()override{ + SMX_Start( SMXStateChangedCallback, this ); + }; + + virtual void OnAfterUserUpdate(float fElapsedTime)override{ + std::string lightData; + for (int pad=0;pad<2;pad++){ + for(int i=0;i<9;i++){ + int row=0; + for(int y=i/3*7;yGetDrawTarget()->GetPixel(x,y)); + lightData.append(1,p.r); + lightData.append(1,p.g); + lightData.append(1,p.b); + col++; + } + row++; + } + } + } + SMX_SetLights2( lightData.data(), lightData.size() ); + } +}; \ No newline at end of file diff --git a/sample/SMXSample.cpp b/sample/SMXSample.cpp index a48059d..5b381c9 100644 --- a/sample/SMXSample.cpp +++ b/sample/SMXSample.cpp @@ -1,37 +1,24 @@ -#include "SMX.h" #define OLC_PGE_APPLICATION #include "olcPixelGameEngine.h" +#include "PGEX_SMX.h" using namespace olc; class SMX_PGE : public olc::PixelGameEngine { + PGEX_SMX smx; public: SMX_PGE() { - sAppName = "Example"; - } - - static void SMXStateChangedCallback(int pad, SMXUpdateCallbackReason reason, void *pUser) - { - SMX_PGE *pSelf = (SMX_PGE*) pUser; - pSelf->SMXStateChanged( pad, reason ); - } - - static void SMXLogCallback(const char *log) - { - printf("-> %s\n", log); - } - - void SMXStateChanged(int pad, SMXUpdateCallbackReason reason) - { - printf("Device %i state changed: %04x\n", pad, SMX_GetInputState(pad)); - + sAppName = "SMX PGE"; } public: bool OnUserCreate() override { - SMX_Start( SMXStateChangedCallback, this ); + SetPixelMode([](const int x,const int y,const Pixel&col,const Pixel&prev){ + + return col; + }); // Called once at the start, so create things here return true; } @@ -50,7 +37,7 @@ public: int main() { SMX_PGE demo; - if (demo.Construct(256, 240, 4, 4)) + if (demo.Construct(12, 21, 50, 50)) demo.Start(); return 0; diff --git a/sample/SMXSample.vcxproj b/sample/SMXSample.vcxproj index 1e153b7..5332ec5 100644 --- a/sample/SMXSample.vcxproj +++ b/sample/SMXSample.vcxproj @@ -101,6 +101,7 @@ + diff --git a/sample/SMXSample.vcxproj.filters b/sample/SMXSample.vcxproj.filters index 6917810..7c581d9 100644 --- a/sample/SMXSample.vcxproj.filters +++ b/sample/SMXSample.vcxproj.filters @@ -18,5 +18,8 @@ Header Files + + Header Files + \ No newline at end of file