androidmcu版本升级包 怎么通知mcu

查看: 1159|回复: 0
基于android2.3.3的MCU驱动
#include &linux/init.h&
#include &linux/module.h&
#include &linux/kernel.h&
#include &linux/moduleparam.h&
#include &linux/device.h&
#include &linux/fs.h&
#include &linux/errno.h&
#include &asm/uaccess.h&
#include &linux/cdev.h&
#include &asm/io.h&
#include &asm/uaccess.h&
#include &asm/mach-types.h&
#include &linux/delay.h&
#if defined(CONFIG_ARCH_TCC88XX)
#include &mach/TCC88xx_Structures.h&
#include &mach/TCC88xx_Physical.h&
#include &linux/interrupt.h&
#include &mach/bsp.h&
#include&linux/51boardpcb.h&
#include &linux/i2c.h&
#include &linux/input.h&
#include &linux/mutex.h&
#include &linux/slab.h&
#include &linux/wait.h&
#include &linux/timer.h&
#include &linux/workqueue.h&
#define MCU_DEBUG& & 1
#if MCU_DEBUG
#define mcu_dbg(fmt, arg...)& &&&printk(fmt, ##arg)
#define mcu_dbg(arg...)
#define MCU_NAME&mcu&
#define MCU_I2C_CH1
#define START_REG& && && &0x35
#define MCU_I2C_ADDRESS& && &0x31
#define MCU_READ0
#define MCU_SEND_CMD1
#define IIC_BLOCK_SIZE& && && && && &512
#define ZAVE_IRQINT_EI1
#define ZIGBEE_IRQINT_EI0
static struct i2c_client *mcu_i2c_
static const struct i2c_device_id mcu_id[] = {
{ MCU_NAME, 0, },
struct mcu_chip {
struct i2c_client *
struct cdev&&
int& &mcu_
unsigned char*
int current_
wait_queue_head_t r_
wait_queue_head_t w_
struct timer_list mcu_
struct work_struct mcu_
static struct mcu_chip* pmcu_
static void mcu_send_cmd(unsigned char reg, unsigned char val)
unsigned char cmd[2];
mcu_dbg(&%s():reg = 0x%x, val = 0x%x\n&, __func__, reg, val);
err = i2c_master_send(mcu_i2c_client, cmd, 2);
if(err & 0)
printk(&mcu_send_cmd error!\n&);
static unsigned char mcu_read_data(unsigned char reg)
err = i2c_master_send(mcu_i2c_client, &reg, 1);
if(err & 0)
printk(&mcu_send_cmd error!\n&);
err = i2c_master_recv(mcu_i2c_client, &buf, 1);
if(err & 0)
printk(&i2c_master_recv error!\n&);
mcu_dbg(&&------%s():buf = 0x%x\n&, __func__, buf);
static int mcu_read_datas(unsigned char reg, unsigned char *buf, unsigned char count)
mcu_dbg(&%s\n&, __func__);
ret = i2c_smbus_read_i2c_block_data(mcu_i2c_client, reg, count, buf);
if (ret & 0) {
dev_err(&mcu_i2c_client-&dev, &failed writings to 0x%02x\n&, reg);
static int mcu_write_datas(unsigned char reg, unsigned char *buf, unsigned char count)
mcu_dbg(&%s\n&, __func__);
ret = i2c_smbus_write_i2c_block_data(mcu_i2c_client, reg, count, buf);
if (ret & 0) {
dev_err(&mcu_i2c_client-&dev, &failed writings to 0x%02x\n&, reg);
static void init_mcu_irq(void)
mcu_dbg(&%s()\n&, __func__);
#if defined(CONFIG_ARCH_TCC88XX)
& & volatile PGPIO pGPIO = (volatile PGPIO)tcc_p2v(HwGPIO_BASE);
& & volatile PPIC pPIC = (volatile PPIC)tcc_p2v(HwPIC_BASE);
//gpioa[6] input zigbee irq ZIGBEE_IRQ INT_EI0
BITCSET(pGPIO-&GPAFN0, Hw27-Hw24, 0);
BITCLR(pGPIO-&GPAEN,&&Hw6);
BITCLR(pGPIO-&GPADAT, Hw6);
//select gpioa[6] irq
& & BITCSET(pGPIO-&EINTSEL0, Hw6-Hw0, 6);
//select INT_EIt0
BITSET(pPIC-&INTMSK0, 1&&ZIGBEE_IRQ);//select INT_EI0
//BITSET(pPIC-&POL0, 1&&ZIGBEE_IRQ);
BITCLR(pPIC-&MODE0, 1&&ZIGBEE_IRQ);& && & //edge trigger
BITCLR(pPIC-&MODEA0, 1&&ZIGBEE_IRQ);& & //single triger
//gpiof[24] input zave irq ZAVE_IRQ&&INT_EI1
BITCSET(pGPIO-&GPFFN3, Hw3-Hw0, 0);
BITCLR(pGPIO-&GPFEN,&&Hw24);
BITCLR(pGPIO-&GPFDAT, Hw24);
//select gpiof[24] irq
& & BITCSET(pGPIO-&EINTSEL0, Hw14-Hw8, 31 && 8);
//select INT_EIt0
BITSET(pPIC-&INTMSK0, 1&&ZAVE_IRQ);//select INT_EI0
& & //BITSET(pPIC-&POL0, 1&&ZAVE_IRQ);
BITCLR(pPIC-&MODE0, 1&&ZAVE_IRQ);& && & //edge trigger
BITCLR(pPIC-&MODEA0, 1&&ZAVE_IRQ);& & //single triger
#endif//TCC88xx
static void mcu_timer_handler(unsigned long data)
struct mcu_chip *chip = container_of((struct timer_list*)data, struct mcu_chip, mcu_timer);
if (schedule_work(&chip-&mcu_work) == 0) {
mcu_dbg(&cannot schedule work !!!\n&);
static void mcu_timer_registertimer(struct timer_list* ptimer, unsigned int timeover )
init_timer(ptimer);
ptimer-&expires = jiffies+msecs_to_jiffies(timeover);
ptimer-&data = (unsigned long)
ptimer-&function = mcu_timer_
add_timer(ptimer);
static void mcu_work(struct work_struct *work)
mcu_dbg(&%s()&, __func__);
struct mcu_chip *chip = i2c_get_clientdata(mcu_i2c_client);
mcu_timer_registertimer(&chip-&mcu_timer, 50 );& &// test
static irqreturn_t zigbee_irq_handler(int irq, void *data)
printk(&Zigbee irq!\n&);
return IRQ_HANDLED;
static irqreturn_t zave_irq_handler(int irq, void *data)
printk(&Zave irq!\n&);
return IRQ_HANDLED;
static int mcu_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
mcu_dbg(&&--------%s\n&, __func__);
pmcu_chip-&buf= kmalloc(IIC_BLOCK_SIZE, GFP_KERNEL);
if (!pmcu_chip-&buf) {
printk(&mcu malloc i2c buf error!\n&);
return -ENOMEM;
pmcu_chip-&client =
i2c_set_clientdata(client, pmcu_chip);
if (!pmcu_chip-&irq_flag) {
enable_irq(ZIGBEE_IRQ);
enable_irq(ZAVE_IRQ);
pmcu_chip-&irq_flag = 1;
static int mcu_i2c_remove(struct i2c_client *client)
mcu_dbg(&&--------%s\n&, __func__);
kfree(pmcu_chip-&buf);
/* mma7660 i2c control layer */
static struct i2c_driver mcu_i2c_driver = {
.driver = {
.name= MCU_NAME,
& && & .owner&&= THIS_MODULE,
.probe= mcu_i2c_probe,
.remove= mcu_i2c_remove,
.id_table= mcu_id,
static int mcu_i2c_register(void)
& & struct i2c_board_
& & struct i2c_adapter *
& & struct i2c_client *
mcu_dbg(&&--------%s\n&, __func__);
& & memset(&info, 0, sizeof(struct i2c_board_info));
& & info.addr = MCU_I2C_ADDRESS;
& & strlcpy(info.type, MCU_NAME, I2C_NAME_SIZE);
& & adapter = i2c_get_adapter(MCU_I2C_CH);
& & if (!adapter)
& && &&&mcu_dbg(KERN_ERR &can't get i2c adapter 0 for mcu\n&);
& && &&&return -ENODEV;
& & client = i2c_new_device(adapter, &info);
& & i2c_put_adapter(adapter);
& & if (!client)
& && &&&mcu_dbg(KERN_ERR &can't add i2c device at 0x%x\n&, (unsigned int)info.addr);
& && &&&return -ENODEV;
& & mcu_i2c_client =
pmcu_chip-&client =
& & return 0;
static ssize_t mcu_write(struct file *file, const char __user *user, size_t size, loff_t *o)
mcu_dbg(&%s\n&, __func__);
DECLARE_WAITQUEUE(wait, current);
struct mcu_chip *chip = i2c_get_clientdata(mcu_i2c_client);
unsigned char *buf = chip-&
unsigned char* debug_buf = chip-&
mutex_lock(&chip-&lock);
add_wait_queue(&chip-&w_wait, &wait);
while(chip-&current_len == IIC_BLOCK_SIZE){
set_current_state(TASK_INTERRUPTIBLE);
mutex_unlock(&chip-&lock);
schedule();
if(size & IIC_BLOCK_SIZE - chip-&current_len)
size = IIC_BLOCK_SIZE - chip-&current_
mutex_lock(&chip-&lock);
if(copy_from_user( buf, (unsigned char*) user, size)){
printk(&copy_from_user error!\n&);
ret = -EFAULT;
wake_up_interruptible(&chip-&r_wait);
mutex_unlock(&chip-&lock);
mcu_dbg(&\n%s\n&, debug_buf);
mcu_dbg(&size = %d\n&, size);
ret = mcu_write_datas(buf[0], ++buf, size - 1);
remove_wait_queue(&chip-&w_wait, &wait);
set_current_state(TASK_RUNNING);
static ssize_t mcu_read(struct file *file, char __user *user, size_t size, loff_t *o)
mcu_dbg(&%s\n&, __func__);
DECLARE_WAITQUEUE(wait, current);
struct mcu_chip *chip = i2c_get_clientdata(mcu_i2c_client);
char *buf = chip-&
mutex_lock(&chip-&lock);
add_wait_queue(&chip-&r_wait, &wait);
while(chip-&current_len == 0){
set_current_state(TASK_INTERRUPTIBLE);
mutex_unlock(&chip-&lock);
schedule();
if(size & chip-&current_len)
size = chip-&current_
ret = mcu_read_datas(buf[0], buf, size);
mutex_lock(&chip-&lock);
if(ret == 0){
if(copy_to_user(user, buf, size)){
printk(&copy_to_user error!\n&);
ret = -EFAULT;
wake_up_interruptible(&chip-&w_wait);
chip-&current_len -=
mutex_unlock(&chip-&lock);
remove_wait_queue(&chip-&r_wait, &wait);
set_current_state(TASK_RUNNING);
static int mcu_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, void *arg)
mcu_dbg(&%s&&(0x%x)&&\n&, __FUNCTION__, cmd);
struct mcu_chip *chip = i2c_get_clientdata(mcu_i2c_client);
switch (cmd)
case MCU_READ:
mcu_dbg(&cmd MCU_READ\n&);
buf = mcu_read_data(START_REG);
mutex_lock(&chip-&lock);
if(copy_to_user((unsigned char*) arg, &buf, sizeof(unsigned char))){
printk(&copy_to_user error!\n&);
return -EFAULT;
mutex_unlock(&chip-&lock);
case MCU_SEND_CMD:
mcu_dbg(&cmd MCU_SEND_CMD\n&);
mutex_lock(&chip-&lock);
if(copy_from_user( &buf, (unsigned char*) arg, sizeof(unsigned char))){
printk(&copy_from_user error!\n&);
return -EFAULT;
mutex_unlock(&chip-&lock);
mcu_send_cmd(START_REG, buf);
static int mcu_release(struct inode *inode, struct file *filp)
i2c_unregister_device(mcu_i2c_client);
i2c_del_driver(&mcu_i2c_driver);
& & mcu_i2c_client = NULL;
static int mcu_open(struct inode *inode, struct file *filp)
mcu_dbg(&&----------%s\n&, __func__);
ret = i2c_add_driver(&mcu_i2c_driver);
if (ret & 0) {
mcu_dbg(&%s() [Error] failed i2c_add_driver() = %d\n&, __func__, ret);
ret = mcu_i2c_register();
if (ret & 0) {
mcu_dbg(&%s() [Error] Failed register i2c client driver for mcu,\n&, __func__);
static struct file_operations mcu_fops =
.owner= THIS_MODULE,
.open= mcu_open,
.release= mcu_release,
.ioctl= mcu_ioctl,
.read& && &= mcu_read,
.write= mcu_write,
static struct class *mcu_
int __init mcu_init(void)
mcu_dbg(&&------ mcu init\n&);
pmcu_chip = kmalloc(sizeof(struct mcu_chip), GFP_KERNEL);
if (!pmcu_chip) {
printk(&mcu malloc error!\n&);
return -ENOMEM;
devno = MKDEV(pmcu_chip-&mcu_major, 0);
ret = alloc_chrdev_region(&devno, 0, 1, MCU_NAME);
pmcu_chip-&mcu_major = MAJOR(devno);
if (ret & 0){
printk(&alloc chardev error!\n&);
kfree(pmcu_chip);
memset(&pmcu_chip-&cdev, 0, sizeof(struct cdev));
cdev_init(&pmcu_chip-&cdev, &mcu_fops);
pmcu_chip-&cdev.owner = THIS_MODULE;
ret = cdev_add(&pmcu_chip-&cdev, MKDEV(pmcu_chip-&mcu_major, 0), 1);
printk(&Error adding mcu cdev\n&);
mcu_class = class_create(THIS_MODULE, MCU_NAME);
device_create(mcu_class, NULL, MKDEV(pmcu_chip-&mcu_major, 0), NULL, MCU_NAME);
mutex_init(&pmcu_chip-&lock);
init_waitqueue_head(&pmcu_chip-&r_wait);
init_waitqueue_head(&pmcu_chip-&w_wait);
INIT_WORK(&pmcu_chip-&mcu_work, mcu_work);
//init arch irq
pmcu_chip-&irq_flag = 0;
init_mcu_irq();
ret = request_irq(ZIGBEE_IRQ, zigbee_irq_handler, IRQF_TRIGGER_FALLING, &zigbee&, NULL);
&&if (ret) {
&&printk(&&-----failed to request zigbee irq!\n&);
kfree(pmcu_chip);
ret = request_irq(ZAVE_IRQ, zave_irq_handler, IRQF_TRIGGER_FALLING, &zave&, NULL);
&&if (ret) {
&&printk(&&-----failed to request zave irq!\n&);
kfree(pmcu_chip);
disable_irq(ZIGBEE_IRQ);
disable_irq(ZAVE_IRQ);
//mcu_timer_registertimer(pmcu_chip-&mcu_major, 50);
void __exit mcu_exit(void)
mcu_dbg(&%s()\n&, __func__);
& & device_destroy(mcu_class, MKDEV(pmcu_chip-&mcu_major, 0));& &
class_destroy(mcu_class);& &
cdev_del(&pmcu_chip-&cdev);& &
unregister_chrdev_region(MKDEV(pmcu_chip-&mcu_major, 0), 1);
kfree(pmcu_chip);
pmcu_chip = NULL;
free_irq(ZAVE_IRQ, NULL);
free_irq(ZIGBEE_IRQ, NULL);
module_init(mcu_init);
module_exit(mcu_exit);
MODULE_AUTHOR(&jingfeng.&);
MODULE_DESCRIPTION(&freescale mc9s08ac16&);
MODULE_LICENSE(&GPL&);
平台:tcc8803&&系统:android2.3.3& & 驱动模块:mc9s08ac16(飞思卡尔单片机)
通讯方式:I2C
功能:主控利用i2c与mcu通讯,mcu根据通讯协议利用uart与zigbee和zave通讯。zigbee,zave上报时,利用mcu产生irq。
& && && && &整个控制流程使用阻塞式驱动。
Powered by匿名用户不能发表回复!|
每天回帖即可获得10分可用分!小技巧:
你还可以输入10000个字符
(Ctrl+Enter)
请遵守CSDN,不得违反国家法律法规。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。昨天一位长期合作的老客户过来,他基于我公司前期的手机方案开发了一些产品,经营的不错,但是有一个问题困扰着他,那就是研发人员很难稳定,所以这次过来想把研发工作完全包给我公司来做,自己全力做业务和维护。对于这个方案,我欣然接受,并且对于他们这类侧重应用的公司,研发人员不稳是正常现象,毕竟所有的技术人员,都想着往更高的技术发展,而应用公司的技术水平有限,这是没办法的。
我之前一直不明白他为什么老养着研发,甚至明明知道研发人员难养,也不愿意把研发包给我们,而这一次他终于决定把研发承包出去,算是相当大的转折。在送他回去的路上,他提到的一句话让我彻底明白:05年的时候,搞搞单片机,加个USB,都算先进的设备了,而今天,都是手机平板方案,单片机根本没法玩,很是落寞。听了这句话,我心中一惊,因为在我眼中,我都没有把他当作技术人员过,因为从手机平台来讲,他根本玩不转,这使我忘记了他之前单片机玩的很好,也算是标准的嵌入式技术人员啊!
就今天来说,不懂手机平台或者平板平台,就算不上嵌入式行业的技术人员,因为MCU在热闹的智能大潮中,显得有些平淡,赢利自然也差很多。幸运的是,我们紧紧的跟着手机平台走,而无论手机平台还是平板平台,他们的核心都是Android平台,只是相比平板平台,手机多了无线移动通讯技术,可以讲,手机平台囊括了所有的嵌入式技术。
我公司擅长于把手机技术应用于行业、工业领域的一家公司,从2008年推出的第一款基于Feature Phone手机开发模块到今天推出的第一款MTK Android智能手机开发模块,有8年时间的应用历史,公交系统、地铁领域、快递行业、安防领域都有我们公司的产品。
此外因为开发高频感应加热电源,从基于MCU51的实用单片机系统(MS)进化到基于STM32的msOS,这样从低端嵌入式平台到高端嵌入式平台,公司都拥有了,并且很完整:
1、MS,基于MCU51
2、msOS,基于STM32,硬件平台是msPLC
3、MTK6572 Android手机开发模块,包括软硬件。
Android平台的学习,不是说会个App就算是玩Android了,它类似低端嵌入式平台,包括软硬件,是一个系统,App等价于低端嵌入式平台的上位机应用。
我公司致力于推广嵌入式技术,立志于建立一个开源、开放的嵌入式平台,欢迎有兴趣的朋友参与。
旗下网站:
与非门科技(北京)有限公司 All Rights Reserved.
京ICP证:070212号
北京市公安局备案编号: 京ICP备:号android 弹出日期滑动选择框,日期滚动滑动选择 - 机遇&速度 - ITeye博客
博客分类:
本例使用到的类比较多,所使用的自定义的控件都是老外写好的,我知识根据他给的滑动的空间的基础上美化下和添加图片罢了,不多说直接看图:
第一步:设计弹出框xml:
&?xml version="1.0" encoding="utf-8"?&
&LinearLayout
xmlns:android="/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
&RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ff424542"
android:orientation="horizontal"
android:layout_above="@+id/bithday_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:layout_centerVertical="true"
android:textColor="@android:color/white"
android:text="日期" /&
android:id="@+id/cancel"
android:layout_width="80dip"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="@drawable/mm_title_btn_right"
android:text="取消"
android:textColor="@android:color/white"
android:id="@+id/submit"
android:layout_width="80dip"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="@drawable/mm_title_act_btn"
android:text="完成"
android:textColor="@android:color/white"
android:layout_alignParentRight="true"
&/RelativeLayout&
&RelativeLayout
android:id="@+id/bithday_layout"
android:layout_alignParentBottom="true"
android:layout_width="fill_parent"
android:layout_height="220dip"
android:gravity="center"
android:orientation="horizontal" &
&LinearLayout
android:layout_width="fill_parent"
android:layout_marginLeft="15dip"
android:layout_marginRight="15dip"
android:layout_height="220dip"
android:gravity="center"
android:orientation="horizontal" &
&com.example.widget.WheelView
android:id="@+id/year"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:layout_weight="1" /&
&com.example.widget.WheelView
android:id="@+id/month"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
&com.example.widget.WheelView
android:id="@+id/day"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
&/LinearLayout&
&FrameLayout
android:layout_width="fill_parent"
android:layout_height="220.0dip"
android:layout_gravity="center"
android:background="@drawable/com_ttshrk_view_scroll_picker_background" &
&/FrameLayout&
&/RelativeLayout&
&/LinearLayout&
第二步:编写弹出框PopupWindow类:
import android.app.A
import android.content.C
import android.graphics.T
import android.graphics.drawable.ColorD
import android.view.LayoutI
import android.view.V
import android.view.View.OnClickL
import android.view.ViewGroup.LayoutP
import android.widget.B
import android.widget.PopupW
import android.widget.TextV
import android.widget.ViewF
import com.example.widget.NumericWheelA
import com.example.widget.OnWheelChangedL
import com.example.widget.WheelV
public class SelectBirthday extends PopupWindow implements OnClickListener {
private Activity mC
private View mMenuV
private ViewF
private Button btn_submit, btn_
private DateNumericAdapter monthAdapter, dayAdapter, yearA
private WheelView year, month,
private int mCurYear = 80, mCurMonth = 5, mCurDay = 14;
private String[] dateT
public SelectBirthday(Activity context) {
super(context);
mContext =
this.age = "";
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mMenuView = inflater.inflate(R.layout.birthday, null);
viewfipper = new ViewFlipper(context);
viewfipper.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
year = (WheelView) mMenuView.findViewById(R.id.year);
month = (WheelView) mMenuView.findViewById(R.id.month);
day = (WheelView) mMenuView.findViewById(R.id.day);
btn_submit = (Button) mMenuView.findViewById(R.id.submit);
btn_cancel = (Button) mMenuView.findViewById(R.id.cancel);
btn_submit.setOnClickListener(this);
btn_cancel.setOnClickListener(this);
Calendar calendar = Calendar.getInstance();
OnWheelChangedListener listener = new OnWheelChangedListener() {
public void onChanged(WheelView wheel, int oldValue, int newValue) {
updateDays(year, month, day);
int curYear = calendar.get(Calendar.YEAR);
if (age != null && age.contains("-")) {
String str[] = age.split("-");
mCurYear = 100 - (curYear - Integer.parseInt(str[0]));
mCurMonth = Integer.parseInt(str[1]) - 1;
mCurDay = Integer.parseInt(str[2]) - 1;
dateType = mContext.getResources().getStringArray(R.array.date);
monthAdapter = new DateNumericAdapter(context, 1, 12, 5);
monthAdapter.setTextType(dateType[1]);
month.setViewAdapter(monthAdapter);
month.setCurrentItem(mCurMonth);
month.addChangingListener(listener);
yearAdapter = new DateNumericAdapter(context, curYear - 100, curYear+100,
100 - 20);
yearAdapter.setTextType(dateType[0]);
year.setViewAdapter(yearAdapter);
year.setCurrentItem(mCurYear);
year.addChangingListener(listener);
updateDays(year, month, day);
day.setCurrentItem(mCurDay);
updateDays(year, month, day);
day.addChangingListener(listener);
viewfipper.addView(mMenuView);
viewfipper.setFlipInterval(6000000);
this.setContentView(viewfipper);
this.setWidth(LayoutParams.FILL_PARENT);
this.setHeight(LayoutParams.WRAP_CONTENT);
this.setFocusable(true);
ColorDrawable dw = new ColorDrawable(0x);
this.setBackgroundDrawable(dw);
this.update();
public void showAtLocation(View parent, int gravity, int x, int y) {
super.showAtLocation(parent, gravity, x, y);
viewfipper.startFlipping();
private void updateDays(WheelView year, WheelView month, WheelView day) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR,
calendar.get(Calendar.YEAR) + year.getCurrentItem());
calendar.set(Calendar.MONTH, month.getCurrentItem());
int maxDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
dayAdapter = new DateNumericAdapter(mContext, 1, maxDays,
calendar.get(Calendar.DAY_OF_MONTH) - 1);
dayAdapter.setTextType(dateType[2]);
day.setViewAdapter(dayAdapter);
int curDay = Math.min(maxDays, day.getCurrentItem() + 1);
day.setCurrentItem(curDay - 1, true);
int years = calendar.get(Calendar.YEAR) - 100;
age = years + "-" + (month.getCurrentItem() + 1) + "-"
+ (day.getCurrentItem() + 1);
* Adapter for numeric wheels. Highlights the current value.
private class DateNumericAdapter extends NumericWheelAdapter {
// Index of current item
int currentI
// Index of item to be highlighted
int currentV
* Constructor
public DateNumericAdapter(Context context, int minValue, int maxValue,
int current) {
super(context, minValue, maxValue);
this.currentValue =
setTextSize(24);
protected void configureTextView(TextView view) {
super.configureTextView(view);
view.setTypeface(Typeface.SANS_SERIF);
public CharSequence getItemText(int index) {
currentItem =
return super.getItemText(index);
public void onClick(View v) {
this.dismiss();
代码主要就是这两个,其他的控件类不是本人编写就不上传了,直接上源码,有需要的自己下载研究
(752.4 KB)
描述: 源码
下载次数: 2381
浏览 34081
请问如何得到日期呢?求帮忙!
浏览: 1282391 次
来自: 深圳
google api key v2
新的不能使用
下载下来可以直接运行,也是我想要的
辛苦楼主了
等了一天.终于下载到了

我要回帖

更多关于 导航mcu升级有什么用 的文章

 

随机推荐