mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-07 01:04:19 +08:00
Add a hex calculator example to NxWM
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4760 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
@@ -140,3 +140,5 @@
|
||||
when a new window is started. It should stay in a maximized state
|
||||
so that it will re-appear with the window above it is closed or
|
||||
minimized.
|
||||
* NxWM::CHexCalculator: Add a hexadecimal/decimal calculator
|
||||
example.
|
||||
|
||||
@@ -31,7 +31,7 @@ PROJECT_NAME = NXWidgets
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = "1.0"
|
||||
PROJECT_NUMBER = "1.1"
|
||||
|
||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||
# base path where the generated documentation will be put.
|
||||
@@ -574,7 +574,7 @@ WARN_LOGFILE =
|
||||
# directories like "/usr/src/myproject". Separate the files or directories
|
||||
# with spaces.
|
||||
|
||||
INPUT = "../libnxwidgets"
|
||||
INPUT = "../libnxwidgets" "../nxwm"
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "ctaskbar.hxx"
|
||||
#include "cstartwindow.hxx"
|
||||
#include "cnxconsole.hxx"
|
||||
#include "chexcalculator.hxx"
|
||||
|
||||
#ifdef CONFIG_NXWM_TOUCHSCREEN
|
||||
# include "ctouchscreen.hxx"
|
||||
@@ -540,6 +541,35 @@ static bool createNxConsole(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: createHexCalculator
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static bool createHexCalculator(void)
|
||||
{
|
||||
// Add the hex calculator application to the start window
|
||||
|
||||
printf("createHexCalculator: Creating the hex calculator application\n");
|
||||
NxWM::CHexCalculatorFactory *calculator = new NxWM::CHexCalculatorFactory(g_nxwmtest.taskbar);
|
||||
if (!calculator)
|
||||
{
|
||||
printf("createHexCalculator: ERROR: Failed to instantiate CHexCalculatorFactory\n");
|
||||
return false;
|
||||
}
|
||||
showTestCaseMemory("createHexCalculator: After creating the hex calculator application");
|
||||
|
||||
printf("createHexCalculator: Adding the hex calculator application to the start window\n");
|
||||
if (!g_nxwmtest.startwindow->addApplication(calculator))
|
||||
{
|
||||
printf("createHexCalculator: ERROR: Failed to add CNxConsoleFactory to the start window\n");
|
||||
delete calculator;
|
||||
return false;
|
||||
}
|
||||
|
||||
showTestCaseMemory("createHexCalculator: After adding the hex calculator application");
|
||||
return true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Public Functions
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -645,6 +675,14 @@ int MAIN_NAME(int argc, char *argv[])
|
||||
testCleanUpAndExit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Create the hex calculator application and add it to the start window
|
||||
|
||||
if (!createHexCalculator())
|
||||
{
|
||||
printf(MAIN_STRING "ERROR: Failed to create the hex calculator application\n");
|
||||
testCleanUpAndExit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Call CTaskBar::startWindowManager to start the display with applications in place.
|
||||
|
||||
if (!startWindowManager())
|
||||
|
||||
@@ -47,4 +47,37 @@
|
||||
* Some of the graphic objects supported by NXWidgets include labels,
|
||||
* buttons, text boxes, button arrays, check boxes, cycle buttons, images,
|
||||
* sliders, scrollable list boxes, progress bars, and more.
|
||||
*
|
||||
* \subsection NXWM\
|
||||
*
|
||||
* NxWM isthe tiny window manager based on NX and NxWidgets. NxWM is a true
|
||||
* multiple window manager but only one window is displayed at a time. This
|
||||
* simplification helps performance on LCD based products (in the same way
|
||||
* that a tiled window manager helps) and also makes the best use of small
|
||||
* displays. It is awkward from a human factors point-of-view trying to
|
||||
* manage multiple windows on a small display.
|
||||
*
|
||||
* The window manager consists of a task bar with icons representing the
|
||||
* running tasks. If you touch the task's icon, it comes to the top. Each
|
||||
* window has a toolbar with (1) a title, (2) a minimize button, and (3) a
|
||||
* stop application button using the standard icons for these things. User
|
||||
* input via a touchscreen or mouse and keyboard is supported.
|
||||
*
|
||||
* There is always a start window that is available in the task bar. When
|
||||
* you touch the start window icon, it brings up the start window containing
|
||||
* icons representing all of the available applications. If you touch an
|
||||
* icon in the start window, it will be started and added to the task bar.
|
||||
*
|
||||
* There is a base class that defines an add-on application and an interface
|
||||
* that supports incorporation of new applications. The only application
|
||||
* that is provided is NxConsole. This is an NSH session running in a window.
|
||||
* You should be able to select the NX icon in the start menu and create as
|
||||
* many NSH sessions in windows as you want. (keybard input still comes
|
||||
* through serial).
|
||||
*
|
||||
* Note 1: NwWM requires NuttX-6.18 or above.
|
||||
*
|
||||
* Note 2: Many of the fundamental classes in NxWidgets derive from the Antony
|
||||
* Dzeryn's "Woopsi" project: http://woopsi.org/ which also has a BSD style
|
||||
* license. See the COPYING file for details.
|
||||
*/
|
||||
|
||||
+16
-5
@@ -44,20 +44,31 @@ CSRCS =
|
||||
|
||||
|
||||
# Window Manager
|
||||
CXXSRCS = capplicationwindow.cxx cfullscreenwindow.cxx cnxconsole.cxx
|
||||
CXXSRCS += cstartwindow.cxx ctaskbar.cxx cwindowmessenger.cxx
|
||||
CXXSRCS = capplicationwindow.cxx cfullscreenwindow.cxx ctaskbar.cxx cwindowmessenger.cxx
|
||||
|
||||
# Device support
|
||||
|
||||
ifeq ($(CONFIG_NXWM_TOUCHSCREEN),y)
|
||||
CXXSRCS += ccalibration.cxx ctouchscreen.cxx
|
||||
CXXSRCS += ctouchscreen.cxx
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NXWM_KEYBOARD),y)
|
||||
CXXSRCS += ckeyboard.cxx
|
||||
endif
|
||||
|
||||
# Applications
|
||||
|
||||
CXXSRCS = cstartwindow.cxx cnxconsole.cxx chexcalculator.cxx
|
||||
|
||||
ifeq ($(CONFIG_NXWM_TOUCHSCREEN),y)
|
||||
CXXSRCS += ccalibration.cxx
|
||||
endif
|
||||
|
||||
|
||||
# Images
|
||||
CXXSRCS += glyph_calibration.cxx glyph_cmd.cxx glyph_minimize.cxx glyph_nsh.cxx
|
||||
CXXSRCS += glyph_play.cxx glyph_start.cxx glyph_stop.cxx
|
||||
CXXSRCS += glyph_calculator.cxx glyph_calibration.cxx glyph_cmd.cxx
|
||||
CXXSRCS += glyph_minimize.cxx glyph_nsh.cxx glyph_play.cxx glyph_start.cxx
|
||||
CXXSRCS += glyph_stop.cxx
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 263 B |
@@ -0,0 +1,276 @@
|
||||
/****************************************************************************
|
||||
* NxWidgets/nxwm/include/chexcalculator.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_CHEXCALCULATOR_HXX
|
||||
#define __INCLUDE_CHEXCALCULATOR_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/nx/nxtk.h>
|
||||
#include <nuttx/nx/nxconsole.h>
|
||||
|
||||
#include "cbuttonarray.hxx"
|
||||
#include "clabel.hxx"
|
||||
|
||||
#include "iapplication.hxx"
|
||||
#include "capplicationwindow.hxx"
|
||||
#include "ctaskbar.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define NXWM_HEXCALCULATOR_NROWS 6
|
||||
#define NXWM_HEXCALCULATOR_NCOLUMNS 6
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
/**
|
||||
* This class implements the NxConsole application.
|
||||
*/
|
||||
|
||||
class CHexCalculator : public IApplication,
|
||||
private IApplicationCallback,
|
||||
private NXWidgets::CWidgetEventHandler
|
||||
{
|
||||
private:
|
||||
CTaskbar *m_taskbar; /**< Reference to the "parent" taskbar */
|
||||
CApplicationWindow *m_window; /**< Reference to the application window */
|
||||
NXWidgets::CButtonArray *m_keypad; /**< The calculator keyboard */
|
||||
NXWidgets::CLabel *m_text; /**< The accumulator text display */
|
||||
struct nxgl_size_s m_windowSize; /**< The size of the calculator window */
|
||||
struct nxgl_size_s m_keypadSize; /**< The size the calculator keypad */
|
||||
struct nxgl_size_s m_buttonSize; /**< The size of one calculator button */
|
||||
struct nxgl_size_s m_textSize; /**< The size of the calculator textbox */
|
||||
struct nxgl_point_s m_keypadPos; /**< The position the calculator keypad */
|
||||
struct nxgl_point_s m_textPos; /**< The position of the calculator textbox */
|
||||
uint64_t m_operand; /**< Previously entered operand */
|
||||
uint64_t m_accum; /**< The current accumulated value */
|
||||
uint64_t m_memory; /**< The current value in memory */
|
||||
uint8_t m_pending; /**< The pending operation */
|
||||
bool m_hexMode; /**< True if in hex mode */
|
||||
|
||||
/**
|
||||
* Select the geometry of the calculator given the current window size.
|
||||
* Only called as part of construction.
|
||||
*/
|
||||
|
||||
inline void setGeometry(void);
|
||||
|
||||
/**
|
||||
* Create the calculator keypad. Only start as part of the applicaiton
|
||||
* start method.
|
||||
*/
|
||||
|
||||
inline bool createCalculator(void);
|
||||
|
||||
/**
|
||||
* Applies labels to the keys.
|
||||
*/
|
||||
|
||||
void labelKeypad(void);
|
||||
|
||||
/**
|
||||
* Show the current value of the accumulator.
|
||||
*/
|
||||
|
||||
void updateText(void);
|
||||
|
||||
/**
|
||||
* Called when the window minimize button is pressed.
|
||||
*/
|
||||
|
||||
void minimize(void);
|
||||
|
||||
/**
|
||||
* Called when the window minimize close is pressed.
|
||||
*/
|
||||
|
||||
void close(void);
|
||||
|
||||
/**
|
||||
* Handle a widget action event. For CImage, this is a button pre-
|
||||
* release event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
void handleActionEvent(const NXWidgets::CWidgetEventArgs &e);
|
||||
|
||||
public:
|
||||
/**
|
||||
* CHexCalculator constructor
|
||||
*
|
||||
* @param window. The application window
|
||||
*
|
||||
* @param taskbar. A pointer to the parent task bar instance
|
||||
* @param window. The window to be used by this application.
|
||||
*/
|
||||
|
||||
CHexCalculator(CTaskbar *taskbar, CApplicationWindow *window);
|
||||
|
||||
/**
|
||||
* CHexCalculator destructor
|
||||
*/
|
||||
|
||||
~CHexCalculator(void);
|
||||
|
||||
/**
|
||||
* Each implementation of IApplication must provide a method to recover
|
||||
* the contained CApplicationWindow instance.
|
||||
*/
|
||||
|
||||
IApplicationWindow *getWindow(void) const;
|
||||
|
||||
/**
|
||||
* Get the icon associated with the application
|
||||
*
|
||||
* @return An instance if IBitmap that may be used to rend the
|
||||
* application's icon. This is an new IBitmap instance that must
|
||||
* be deleted by the caller when it is no long needed.
|
||||
*/
|
||||
|
||||
NXWidgets::IBitmap *getIcon(void);
|
||||
|
||||
/**
|
||||
* Get the name string associated with the application
|
||||
*
|
||||
* @return A copy if CNxString that contains the name of the application.
|
||||
*/
|
||||
|
||||
NXWidgets::CNxString getName(void);
|
||||
|
||||
/**
|
||||
* Start the application (perhaps in the minimized state).
|
||||
*
|
||||
* @return True if the application was successfully started.
|
||||
*/
|
||||
|
||||
bool run(void);
|
||||
|
||||
/**
|
||||
* Stop the application.
|
||||
*/
|
||||
|
||||
void stop(void);
|
||||
|
||||
/**
|
||||
* Destroy the application and free all of its resources. This method
|
||||
* will initiate blocking of messages from the NX server. The server
|
||||
* will flush the window message queue and reply with the blocked
|
||||
* message. When the block message is received by CWindowMessenger,
|
||||
* it will send the destroy message to the start window task which
|
||||
* will, finally, safely delete the application.
|
||||
*/
|
||||
|
||||
void destroy(void);
|
||||
|
||||
/**
|
||||
* The application window is hidden (either it is minimized or it is
|
||||
* maximized, but not at the top of the hierarchy
|
||||
*/
|
||||
|
||||
void hide(void);
|
||||
|
||||
/**
|
||||
* Redraw the entire window. The application has been maximized or
|
||||
* otherwise moved to the top of the hierarchy. This method is call from
|
||||
* CTaskbar when the application window must be displayed
|
||||
*/
|
||||
|
||||
void redraw(void);
|
||||
|
||||
/**
|
||||
* Report of this is a "normal" window or a full screen window. The
|
||||
* primary purpose of this method is so that window manager will know
|
||||
* whether or not it show draw the task bar.
|
||||
*
|
||||
* @return True if this is a full screen window.
|
||||
*/
|
||||
|
||||
bool isFullScreen(void) const;
|
||||
};
|
||||
|
||||
class CHexCalculatorFactory : public IApplicationFactory
|
||||
{
|
||||
private:
|
||||
CTaskbar *m_taskbar; /**< The taskbar */
|
||||
|
||||
public:
|
||||
/**
|
||||
* CHexCalculatorFactory Constructor
|
||||
*
|
||||
* @param taskbar. The taskbar instance used to terminate calibration
|
||||
*/
|
||||
|
||||
CHexCalculatorFactory(CTaskbar *taskbar);
|
||||
|
||||
/**
|
||||
* CHexCalculatorFactory Destructor
|
||||
*/
|
||||
|
||||
inline ~CHexCalculatorFactory(void) { }
|
||||
|
||||
/**
|
||||
* Create a new instance of an CHexCalculator (as IApplication).
|
||||
*/
|
||||
|
||||
IApplication *create(void);
|
||||
|
||||
/**
|
||||
* Get the icon associated with the application
|
||||
*
|
||||
* @return An instance if IBitmap that may be used to rend the
|
||||
* application's icon. This is an new IBitmap instance that must
|
||||
* be deleted by the caller when it is no long needed.
|
||||
*/
|
||||
|
||||
NXWidgets::IBitmap *getIcon(void);
|
||||
};
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __INCLUDE_CHEXCALCULATOR_HXX
|
||||
@@ -172,7 +172,8 @@ namespace NxWM
|
||||
void removeAllApplications(void);
|
||||
|
||||
/**
|
||||
* Handle a widget action event. For CImage, this is a mouse button pre-release event.
|
||||
* Handle a widget action event. For CButtonArray, this is a mouse
|
||||
* button pre-release event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
@@ -509,6 +509,24 @@
|
||||
# define CONFIG_NXWM_CALIBRATION_LISTENERSTACK 2048
|
||||
#endif
|
||||
|
||||
/* Hexcalculator applications ***********************************************/
|
||||
/**
|
||||
* Calibration display settings:
|
||||
*
|
||||
* CONFIG_NXWM_HEXCALCULATOR_BACKGROUNDCOLOR - The background color of the
|
||||
* calculator display. Default: Same as CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR
|
||||
* CONFIG_NXWM_HEXCALCULATOR_ICON - The ICON to use for the hex calculator
|
||||
* application. Default: NxWM::g_calculatorBitmap
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWM_HEXCALCULATOR_BACKGROUNDCOLOR
|
||||
# define CONFIG_NXWM_HEXCALCULATOR_BACKGROUNDCOLOR CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NXWM_HEXCALCULATOR_ICON
|
||||
# define CONFIG_NXWM_HEXCALCULATOR_ICON NxWM::g_calculatorBitmap
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Global Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
extern const struct NXWidgets::SRlePaletteBitmap g_calculatorBitmap;
|
||||
extern const struct NXWidgets::SRlePaletteBitmap g_calibrationBitmap;
|
||||
extern const struct NXWidgets::SRlePaletteBitmap g_cmdBitmap;
|
||||
extern const struct NXWidgets::SRlePaletteBitmap g_minimizeBitmap;
|
||||
|
||||
@@ -536,7 +536,7 @@ void CCalibration::stateMachine(void)
|
||||
// Fill the entire window with the background color
|
||||
|
||||
port->drawFilledRect(0, 0, windowSize.w, windowSize.h,
|
||||
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR);
|
||||
CONFIG_NXWM_CALIBRATION_BACKGROUNDCOLOR);
|
||||
|
||||
// Then draw the first calibration screen
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,191 @@
|
||||
/********************************************************************************************
|
||||
* NxWidgets/nxwm/src/glyph_calculator.cxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
/********************************************************************************************
|
||||
* Included Files
|
||||
********************************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
#include <nuttx/fb.h>
|
||||
#include <nuttx/rgbcolors.h>
|
||||
|
||||
#include "crlepalettebitmap.hxx"
|
||||
|
||||
#include "nxwmconfig.hxx"
|
||||
#include "nxwmglyphs.hxx"
|
||||
|
||||
/********************************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
********************************************************************************************/
|
||||
|
||||
#define BITMAP_NROWS 25
|
||||
#define BITMAP_NCOLUMNS 24
|
||||
#define BITMAP_NLUTCODES 8
|
||||
|
||||
/********************************************************************************************
|
||||
* Private Bitmap Data
|
||||
********************************************************************************************/
|
||||
|
||||
using namespace NxWM;
|
||||
|
||||
/* RGB24 (8-8-8) Colors */
|
||||
|
||||
#if CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
|
||||
|
||||
static const uint32_t g_calculatorNormalLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
0xfcfcfc, 0xb8bcbc, 0xf8f8f8, 0x6890c8, 0x384c80, 0xe8e8e8, 0x646464, 0x909090 /* Codes 0-7 */
|
||||
};
|
||||
|
||||
static const uint32_t g_calculatorBrightlLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
0xffffff, 0xc9cccc, 0xf9f9f9, 0x8dabd5, 0x69789f, 0xededed, 0x8a8a8a, 0xababab /* Codes 0-7 */
|
||||
};
|
||||
|
||||
/* RGB16 (565) Colors (four of the colors in this map are duplicates) */
|
||||
|
||||
#elif CONFIG_NXWIDGETS_BPP == 16
|
||||
|
||||
static const uint16_t g_calculatorNormalLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
0xffff, 0xbdf7, 0xffdf, 0x6c99, 0x3a70, 0xef5d, 0x632c, 0x9492 /* Codes 0-7 */
|
||||
};
|
||||
|
||||
static const uint16_t g_calculatorBrightlLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
0xffff, 0xce79, 0xffdf, 0x8d5a, 0x6bd3, 0xef7d, 0x8c51, 0xad55 /* Codes 0-7 */
|
||||
};
|
||||
|
||||
/* 8-bit color lookups. NOTE: This is really dumb! The lookup index is 8-bits and it used
|
||||
* to lookup an 8-bit value. There is no savings in that! It would be better to just put
|
||||
* the 8-bit color/greyscale value in the run-length encoded image and save the cost of these
|
||||
* pointless lookups. But these p;ointless lookups do make the logic compatible with the
|
||||
* 16- and 24-bit types.
|
||||
*/
|
||||
|
||||
#elif CONFIG_NXWIDGETS_BPP == 8
|
||||
# ifdef CONFIG_NXWIDGETS_GREYSCALE
|
||||
|
||||
static const uint8_t g_calculatorNormalLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
0xfc, 0xba, 0xf8, 0x8a, 0x4b, 0xe8, 0x64, 0x90 /* Codes 0-7 */
|
||||
};
|
||||
|
||||
static const uint8_t g_calculatorBrightlLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
0xff, 0xcb, 0xf9, 0xa6, 0x77, 0xed, 0x8a, 0xab /* Codes 0-7 */
|
||||
};
|
||||
|
||||
# else /* CONFIG_NXWIDGETS_GREYSCALE */
|
||||
|
||||
static const nxgl_mxpixel_t g_calculatorNormalLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
0xff, 0xb7, 0xff, 0x73, 0x2a, 0xff, 0x6d, 0x92 /* Codes 0-7 */
|
||||
};
|
||||
|
||||
static const nxgl_mxpixel_t g_calculatorBrightlLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
0xff, 0xdb, 0xff, 0x97, 0x6e, 0xff, 0x92, 0xb6 /* Codes 0-7 */
|
||||
};
|
||||
|
||||
# endif /* CONFIG_NXWIDGETS_GREYSCALE */
|
||||
#else
|
||||
# error "Unsupport pixel format"
|
||||
#endif
|
||||
|
||||
static const struct NXWidgets::SRlePaletteBitmapEntry g_calculatorRleEntries[] =
|
||||
{
|
||||
{ 23, 0}, { 1, 1}, /* Row 0 */
|
||||
{ 1, 0}, { 21, 1}, { 1, 2}, { 1, 1}, /* Row 1 */
|
||||
{ 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 2 */
|
||||
{ 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 3 */
|
||||
{ 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 4 */
|
||||
{ 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 5 */
|
||||
{ 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 6 */
|
||||
{ 1, 2}, { 1, 1}, { 20, 4}, { 1, 0}, { 1, 1}, /* Row 7 */
|
||||
{ 1, 2}, { 1, 1}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, /* Row 8 */
|
||||
{ 4, 5}, { 1, 6}, { 1, 0}, { 1, 1},
|
||||
{ 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 9 */
|
||||
{ 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
|
||||
{ 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 10 */
|
||||
{ 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
|
||||
{ 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 11 */
|
||||
{ 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
|
||||
{ 1, 0}, { 1, 1}, { 20, 6}, { 1, 0}, { 1, 1}, /* Row 12 */
|
||||
{ 1, 0}, { 1, 1}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, /* Row 13 */
|
||||
{ 4, 5}, { 1, 6}, { 1, 0}, { 1, 1},
|
||||
{ 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 14 */
|
||||
{ 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
|
||||
{ 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 15 */
|
||||
{ 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
|
||||
{ 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 16 */
|
||||
{ 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
|
||||
{ 1, 0}, { 1, 1}, { 20, 6}, { 1, 0}, { 1, 1}, /* Row 17 */
|
||||
{ 1, 2}, { 1, 1}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, /* Row 18 */
|
||||
{ 4, 5}, { 1, 6}, { 1, 0}, { 1, 1},
|
||||
{ 1, 2}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 19 */
|
||||
{ 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
|
||||
{ 1, 2}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 20 */
|
||||
{ 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
|
||||
{ 1, 2}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 21 */
|
||||
{ 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
|
||||
{ 1, 2}, { 1, 1}, { 20, 6}, { 1, 0}, { 1, 1}, /* Row 22 */
|
||||
{ 23, 0}, { 1, 1}, /* Row 23 */
|
||||
{ 24, 1} /* Row 24 */
|
||||
};
|
||||
|
||||
/********************************************************************************************
|
||||
* Public Bitmap Structure Defintions
|
||||
********************************************************************************************/
|
||||
|
||||
const struct NXWidgets::SRlePaletteBitmap NxWM::g_calculatorBitmap =
|
||||
{
|
||||
CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
|
||||
CONFIG_NXWIDGETS_FMT, // fmt - Color format
|
||||
BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT)
|
||||
BITMAP_NCOLUMNS, // width - Width in pixels
|
||||
BITMAP_NROWS, // height - Height in rows
|
||||
{ // lut - Pointer to the beginning of the Look-Up Table (LUT)
|
||||
g_calculatorNormalLut, // Index 0: Unselected LUT
|
||||
g_calculatorBrightlLut, // Index 1: Selected LUT
|
||||
},
|
||||
g_calculatorRleEntries // data - Pointer to the beginning of the RLE data
|
||||
};
|
||||
Reference in New Issue
Block a user