3
3
import cv2
4
4
5
5
# Derived from:
6
- # https:// github.com/openmv/openmv/blob/5acf5baf92b4314a549bdd068138e5df6cc0bac7/drivers/sensors/hm01b0.c
6
+ # https:# github.com/openmv/openmv/blob/5acf5baf92b4314a549bdd068138e5df6cc0bac7/drivers/sensors/hm01b0.c
7
7
class HM01B0 (DVP_Camera ):
8
8
9
9
# Read only registers
@@ -128,6 +128,8 @@ class HM01B0(DVP_Camera):
128
128
HIMAX_FRAME_LENGTH_QQVGA = 0x084
129
129
130
130
INIT_COMMANDS = (
131
+ (BLC_TGT , 0x08 ), # BLC target :8 at 8 bit mode
132
+ (BLC2_TGT , 0x08 ), # BLI target :8 at 8 bit mode
131
133
(0x3044 , 0x0A ), # Increase CDS time for settling
132
134
(0x3045 , 0x00 ), # Make symmetric for cds_tg and rst_tg
133
135
(0x3047 , 0x0A ), # Increase CDS time for settling
@@ -145,10 +147,36 @@ class HM01B0(DVP_Camera):
145
147
(0x3065 , 0x04 ), # pad pull 0
146
148
(ANA_Register_17 , 0x00 ), # Disable internal oscillator
147
149
150
+ (BLC_CFG , 0x43 ), # BLC_on, IIR
151
+
152
+ (0x1001 , 0x43 ), # BLC dithering en
153
+ (0x1002 , 0x43 ), # blc_darkpixel_thd
154
+ (0x0350 , 0x7F ), # Dgain Control
155
+ (BLI_EN , 0x01 ), # BLI enable
156
+ (0x1003 , 0x00 ), # BLI Target [Def: 0x20]
157
+
158
+ (DPC_CTRL , 0x01 ), # DPC option 0: DPC off 1 : mono 3 : bayer1 5 : bayer2
159
+ (0x1009 , 0xA0 ), # cluster hot pixel th
160
+ (0x100A , 0x60 ), # cluster cold pixel th
161
+ (SINGLE_THR_HOT , 0x90 ), # single hot pixel th
162
+ (SINGLE_THR_COLD , 0x40 ), # single cold pixel th
148
163
(0x1012 , 0x00 ), # Sync. shift disable
164
+ (STATISTIC_CTRL , 0x07 ), # AE stat en | MD LROI stat en | magic
165
+ (0x2003 , 0x00 ),
166
+ (0x2004 , 0x1C ),
167
+ (0x2007 , 0x00 ),
168
+ (0x2008 , 0x58 ),
169
+ (0x200B , 0x00 ),
170
+ (0x200C , 0x7A ),
171
+ (0x200F , 0x00 ),
172
+ (0x2010 , 0xB8 ),
173
+ (0x2013 , 0x00 ),
174
+ (0x2014 , 0x58 ),
175
+ (0x2017 , 0x00 ),
176
+ (0x2018 , 0x9B ),
149
177
150
178
(AE_CTRL , 0x01 ), #Automatic Exposure
151
- (AE_TARGET_MEAN , 0x80 ), #AE target mean [Def: 0x3C]
179
+ (AE_TARGET_MEAN , 0x64 ), #AE target mean [Def: 0x3C]
152
180
(AE_MIN_MEAN , 0x0A ), #AE min target mean [Def: 0x0A]
153
181
(CONVERGE_IN_TH , 0x03 ), #Converge in threshold [Def: 0x03]
154
182
(CONVERGE_OUT_TH , 0x05 ), #Converge out threshold [Def: 0x05]
@@ -165,12 +193,23 @@ class HM01B0(DVP_Camera):
165
193
(DIGITAL_GAIN_H , 0x01 ), #Digital Gain High [Def: 0x01]
166
194
(DIGITAL_GAIN_L , 0x00 ), #Digital Gain Low [Def: 0x00]
167
195
196
+ (FS_CTRL , 0x00 ), #Flicker Control
197
+
198
+ (FS_60HZ_H , 0x00 ),
199
+ (FS_60HZ_L , 0x3C ),
200
+ (FS_50HZ_H , 0x00 ),
201
+ (FS_50HZ_L , 0x32 ),
202
+
168
203
(MD_CTRL , 0x00 ),
169
204
(FRAME_LEN_LINES_H , HIMAX_FRAME_LENGTH_QVGA >> 8 ),
170
205
(FRAME_LEN_LINES_L , HIMAX_FRAME_LENGTH_QVGA & 0xFF ),
171
206
(LINE_LEN_PCK_H , HIMAX_LINE_LEN_PCK_QVGA >> 8 ),
172
207
(LINE_LEN_PCK_L , HIMAX_LINE_LEN_PCK_QVGA & 0xFF ),
173
208
(QVGA_WIN_EN , 0x01 ), # Enable QVGA window readout
209
+ (0x0383 , 0x01 ),
210
+ (0x0387 , 0x01 ),
211
+ (0x0390 , 0x00 ),
212
+ (0x3011 , 0x70 ),
174
213
(0x3059 , 0x22 ), # 1-bit mode
175
214
(OSC_CLK_DIV , 0x14 ),
176
215
(IMG_ORIENTATION , 0x00 ), # change the orientation
@@ -217,7 +256,14 @@ def soft_reset(self):
217
256
Performs a software reset of the HM01B0 sensor.
218
257
This resets the sensor to its default state.
219
258
"""
220
- self .writeRegister (self .SW_RESET , self .HIMAX_RESET )
259
+ # HM01B0 can require multiple attempts to reset properly
260
+ for i in range (self .HIMAX_BOOT_RETRY ):
261
+ self .writeRegister (self .SW_RESET , self .HIMAX_RESET )
262
+ sleep_us (1000 )
263
+ mode = self .readRegister (self .MODE_SELECT )
264
+ if mode [0 ] == self .HIMAX_MODE_STANDBY :
265
+ break
266
+ sleep_us (10000 )
221
267
222
268
def setMode (self , mode ):
223
269
"""
0 commit comments