1 /** 2 * @file lv_spinbox.h 3 * 4 */ 5 6 #ifndef LV_SPINBOX_H 7 #define LV_SPINBOX_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /********************* 14 * INCLUDES 15 *********************/ 16 #include "../textarea/lv_textarea.h" 17 18 #if LV_USE_SPINBOX 19 20 /*Testing of dependencies*/ 21 #if LV_USE_TEXTAREA == 0 22 #error "lv_spinbox: lv_ta is required. Enable it in lv_conf.h (LV_USE_TEXTAREA 1) " 23 #endif 24 25 /********************* 26 * DEFINES 27 *********************/ 28 #define LV_SPINBOX_MAX_DIGIT_COUNT 10 29 30 /********************** 31 * TYPEDEFS 32 **********************/ 33 34 LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_spinbox_class; 35 36 /********************** 37 * GLOBAL PROTOTYPES 38 **********************/ 39 40 /** 41 * Create a spinbox object 42 * @param parent pointer to an object, it will be the parent of the new spinbox 43 * @return pointer to the created spinbox 44 */ 45 lv_obj_t * lv_spinbox_create(lv_obj_t * parent); 46 47 /*===================== 48 * Setter functions 49 *====================*/ 50 51 /** 52 * Set spinbox value 53 * @param obj pointer to spinbox 54 * @param v value to be set 55 */ 56 void lv_spinbox_set_value(lv_obj_t * obj, int32_t v); 57 58 /** 59 * Set spinbox rollover function 60 * @param obj pointer to spinbox 61 * @param rollover true or false to enable or disable (default) 62 */ 63 void lv_spinbox_set_rollover(lv_obj_t * obj, bool rollover); 64 65 /** 66 * Set spinbox digit format (digit count and decimal format) 67 * @param obj pointer to spinbox 68 * @param digit_count number of digit excluding the decimal separator and the sign 69 * @param sep_pos number of digit before the decimal point. If 0, decimal point is not 70 * shown 71 */ 72 void lv_spinbox_set_digit_format(lv_obj_t * obj, uint32_t digit_count, uint32_t sep_pos); 73 74 /** 75 * Set spinbox step 76 * @param obj pointer to spinbox 77 * @param step steps on increment/decrement. Can be 1, 10, 100, 1000, etc the digit that will change. 78 */ 79 void lv_spinbox_set_step(lv_obj_t * obj, uint32_t step); 80 81 /** 82 * Set spinbox value range 83 * @param obj pointer to spinbox 84 * @param range_min maximum value, inclusive 85 * @param range_max minimum value, inclusive 86 */ 87 void lv_spinbox_set_range(lv_obj_t * obj, int32_t range_min, int32_t range_max); 88 89 /** 90 * Set cursor position to a specific digit for edition 91 * @param obj pointer to spinbox 92 * @param pos selected position in spinbox 93 */ 94 void lv_spinbox_set_cursor_pos(lv_obj_t * obj, uint32_t pos); 95 96 /** 97 * Set direction of digit step when clicking an encoder button while in editing mode 98 * @param obj pointer to spinbox 99 * @param direction the direction (LV_DIR_RIGHT or LV_DIR_LEFT) 100 */ 101 void lv_spinbox_set_digit_step_direction(lv_obj_t * obj, lv_dir_t direction); 102 103 /*===================== 104 * Getter functions 105 *====================*/ 106 107 /** 108 * Get spinbox rollover function status 109 * @param obj pointer to spinbox 110 */ 111 bool lv_spinbox_get_rollover(lv_obj_t * obj); 112 113 /** 114 * Get the spinbox numeral value (user has to convert to float according to its digit format) 115 * @param obj pointer to spinbox 116 * @return value integer value of the spinbox 117 */ 118 int32_t lv_spinbox_get_value(lv_obj_t * obj); 119 120 /** 121 * Get the spinbox step value (user has to convert to float according to its digit format) 122 * @param obj pointer to spinbox 123 * @return value integer step value of the spinbox 124 */ 125 int32_t lv_spinbox_get_step(lv_obj_t * obj); 126 127 /*===================== 128 * Other functions 129 *====================*/ 130 131 /** 132 * Select next lower digit for edition by dividing the step by 10 133 * @param obj pointer to spinbox 134 */ 135 void lv_spinbox_step_next(lv_obj_t * obj); 136 137 /** 138 * Select next higher digit for edition by multiplying the step by 10 139 * @param obj pointer to spinbox 140 */ 141 void lv_spinbox_step_prev(lv_obj_t * obj); 142 143 /** 144 * Increment spinbox value by one step 145 * @param obj pointer to spinbox 146 */ 147 void lv_spinbox_increment(lv_obj_t * obj); 148 149 /** 150 * Decrement spinbox value by one step 151 * @param obj pointer to spinbox 152 */ 153 void lv_spinbox_decrement(lv_obj_t * obj); 154 155 /********************** 156 * MACROS 157 **********************/ 158 159 #endif /*LV_USE_SPINBOX*/ 160 161 #ifdef __cplusplus 162 } /*extern "C"*/ 163 #endif 164 #endif /*LV_SPINBOX_H*/ 165